Current_timestamp minus days

02 April,2014 by Jack Vamvas

Question:Do you know how to write a query in DB2 that would display records based on the last month eg. Take todays date and then  display last 31 days ?  In other words, I need to subtract some days from a timestamp

Answer: Without  actual details I can’t supply a specific query, but I can share with you a pattern, allowing you to apply in your query.

The basic concept:

CURRENT_TIMESTAMP - 31 DAYS

This example query will return the date from 31 days ago

 

db2 "select date(current timestamp – 31 days) from sysibm.sysdummy1"

 

How you  construct the statement  will depend on the column used to store the dates

Read More

Last time DB2 REORG was executed

DB2 – 10 Top Skills for Architects

 

Author: Jack Vamvas(http://www.dba-db2.com)

Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on Current_timestamp minus days

Comments are moderated, and will not appear until the author has approved them.


dba-db2.com | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright