Nov 112013
 

If you work with clients with in different timezones, be wary of the CURRENT_DATE/CURRENT_TIMESTAMP functions:

select (current_date - sysdate)
         as greater_than_zero
from   your_database
where  dbtimezone <> sessiontimezone;

There’s posts timezone issues in more detail from Jonathan Lewis and Tony Hasler. For a quick example script, keep reading.

-- my DB server is configured with PST
alter session set time_zone = 'PST';

-- so current_date = sysdate
select current_date - sysdate 
         as equal_to_zero
from   dual;

-- but now client <> server ...
alter session set time_zone = 'GMT';

-- the values are different...
select current_date - sysdate 
         as greater_than_zero
from   dual;
Get SQLfail sent to your inbox

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>