I’m trying to query data that happened between Yesterday 6 AM and Today 6 AM.
I’m having a problem in concatenation.
This is what I’ve tried.
Where update_time between date(CURRENT DATE,'mm/dd/yyyy 06:00:00')- 1 DAYS
and date(CURRENT DATE,'mm/dd/yyyy 06:00:00')
Try this:
Updated to answer X-Zero’s comment:
The DB2 function
CHAR(CURRENT DATE,ISO)takes the current date, and converts it to a character string in theISOformat. Taking today’s date, the CHAR function would return “2012-09-18”.Next, we concatenate (||) a time string to the date string. The space in the time string creates a character DB2 timestamp in the correct format. “2012-09-18 06:00:00”.
Finally, the DB2 function
TIMESTAMPtakes the character DB2 timestamp and converts it to an actual DB2 timestamp.