Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

H2 SQL Date Comparison

Tags:

sql

datetime

h2

In an H2 database on a column of type TIMESTAMP how do I run a query

SELECT * FROM RECORDS WHERE TRAN_DATE < '2012/07/24'
like image 484
John Oxley Avatar asked Jul 24 '12 15:07

John Oxley


People also ask

How can I compare two dates in SQL?

This can be easily done using equals to(=), less than(<), and greater than(>) operators. In SQL, the date value has DATE datatype which accepts date in 'yyyy-mm-dd' format. To compare two dates, we will declare two dates and compare them using the IF-ELSE statement.

What is the date format in H2 database?

The format is hh:mm:ss[. nnnnnnnnn].

How do you compare dates in MySQL?

MySQL has the ability to compare two different dates written as a string expression. When you need to compare dates between a date column and an arbitrary date, you can use the DATE() function to extract the date part from your column and compare it with a string that represents your desired date.

Is null in H2?

And when inserting an empty string in H2 with MODE=Oracle it is not converted to NULL whereas in Oracle DB NULL is stored and not an empty string.


1 Answers

Try '2012-07-24'

http://www.h2database.com/html/grammar.html?highlight=dateType&search=date#date

like image 56
Robert Harvey Avatar answered Sep 20 '22 20:09

Robert Harvey