Pages

Thursday, September 30, 2010

DB2 -=- Select between two timestamps

Hi

If you want to retrieve data between two timestamp, you can type the following request.


SELECT * 
FROM MYDB.MYTABLE
WHERE MYTIMESTAMPFIELD 
BETWEEN (SELECT current timestamp -1 MONTH FROM SYSIBM.SYSDUMMY1)  
and (SELECT current timestamp FROM SYSIBM.SYSDUMMY1)

You can use the following duration with current timestamp
  • YEAR
  • MONTH
  • DAY
  • HOUR
  • MINUTE
  • SECOND
  • MICROSECOND

No comments:

Post a Comment