Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Subtracting Minutes from SYSTIMESTAMP or SYSDATE in H2 not working

Subtracting Minutes from SYSTIMESTAMP or SYSDATE in H2 not working .The result for following two commands are same:

select SYSTIMESTAMP from dual;    

select SYSTIMESTAMP- 30 / 1440 from dual;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

That math only works for DATE data types (e.g. SYSDATE), not for TIMESTAMP. For TIMESTAMP, use the INTERVAL function:

select systimestamp, systimestamp - interval '30' second from dual;

SYSTIMESTAMP                        SYSTIMESTAMP-INTERVAL'30'SECOND    
----------------------------------- -----------------------------------
13-APR-22 03.34.41.414075000 PM GMT 13-APR-22 03.34.11.414075000 PM GMT

See here for a thorough explanation of the differences in the two data types and their operations: https://oracle-base.com/articles/misc/oracle-dates-timestamps-and-intervals

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading