-1

i am using spring jdbc template. i am compairing time in query which is not working as sysdate consider timezone.

select * from Emp where TSLASTMODIFIED < SYSDATE - (  45/(24*60));
yusuf
  • 73
  • 1
  • 9
  • possible duplicate of [How to get UTC value for SYSDATE on Oracle](http://stackoverflow.com/questions/1157873/how-to-get-utc-value-for-sysdate-on-oracle) – Klas Lindbäck Nov 06 '14 at 11:22
  • am calling this from java, not running directly on sql or toad – yusuf Nov 06 '14 at 12:19
  • You don't have any Java code here... how are we meant to know that this is related to Java? If the SQL you're running is not returning the correct the result then the fact that you're calling the SQL in Java doesn't matter. – Ben Nov 06 '14 at 12:33
  • ok, i am calling the above mention sql query from java code. when i run the same query in toad its give me correct result but when i call it from java code it give me wrong result . it seems something related to timezine issue with sysdate. Can you help now – yusuf Nov 06 '14 at 12:58
  • What's the data type of the TSLASTMODIFIED column? – Bob Jarvis - Слава Україні Nov 06 '14 at 13:19

1 Answers1

0

If you apply the information in the linked answer you get:

select * from Emp where TSLASTMODIFIED < CAST(sys_extract_utc(SYSTIMESTAMP) AS DATE) - (  45/(24*60));

If TSLASTMODIFIED uses some other timezone than UTC you need to modify the SQL accordingly.

Community
  • 1
  • 1
Klas Lindbäck
  • 33,105
  • 5
  • 57
  • 82