Nicolazz92
Nicolazz92

Reputation: 138

H2 DB - Set time part in timestamp

I'm writing a population script for H2 DB. I have a timestamp, this timestamp always has to be "yesterday", and it's time part has to be at 08:30. I tryed something like

DATEADD('DAY', -1, TIMESTAMPADD('MINUTE', TIMESTAMPDIFF('MINUTE', CURRENT_TIME, '08:30:00'), CURRENT_TIMESTAMP))

but H2 says that "Cannot parse "TIMESTAMP" constant "08:30:00"; SQL statement".

I don't want to do it in java, do you know some way to set time? Thanks:)

Upvotes: 1

Views: 2129

Answers (1)

Cepr0
Cepr0

Reputation: 30349

For example:

select timestampadd('minute', 510, dateadd('day',-1, today()))

First we use dateadd to shift back by '-1' 'day' from 'today()', then we use timestampadd to shift forward by '+510' 'minute's (8:30).

Upvotes: 1

Related Questions