Re: [h2] Compare timestamp and date

1,126 views
Skip to first unread message

Thomas Mueller

unread,
Jun 5, 2013, 1:59:07 PM6/5/13
to H2 Google Group
Hi,

Could you cast it to a date, and then compare dates?

Regards,
Thomas



On Wed, Jun 5, 2013 at 5:43 PM, Pierre <pierz...@gmail.com> wrote:
Hello, how to compare a timestamp with a date? I want to select all the record where the timestamp match the date '2013-06-05' , something like :

select * from table where thetimestamp = '2013-06-05'

It won't work be cause it will only match '2013-06-05 00:00:00.0' timestamp but not '2013-06-05 12:13:40.4'.

How to do it the right way ? I think I can do something like :

select * from table where thetimestamp > '2013-06-04' and thetimestamp < '2013-06-06'

 
but it's very very ugly. Thanks.

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database...@googlegroups.com.
To post to this group, send email to h2-da...@googlegroups.com.
Visit this group at http://groups.google.com/group/h2-database?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Noel Grandin

unread,
Jun 6, 2013, 4:33:06 AM6/6/13
to h2-da...@googlegroups.com, Pierre
TRUNC() will convert a timestamp to a date

Pierre

unread,
Jun 12, 2013, 11:20:43 AM6/12/13
to h2-da...@googlegroups.com, Pierre
select cast(current_timestamp as date); is OK but TRUNC() doesn't work
Reply all
Reply to author
Forward
0 new messages