Page 1 of 1

Timestamp in DB2

Posted: Wed Aug 25, 2004 1:09 pm
by rkumar28
Hi,

I am extrating data from DB2 using DataStage native API for DB2/UDB. I have a User defined SQL. Based on the SQL logic the data is extracted weekly to a pipe delimited file and FTPed.

I need some giudance with a portion of SQL query below. I extract one week data from the table with the logic below:

Select ....... from table1
where
....
AND
Schema1.TableName.TIMECREATED BETWEEN '2004-08-12 00:00:00.000000' AND '2004-08-19 00:00:00.000000'

Every week I change the timestamp and make it between one week. Is there a default command for Timestamp in DB2 (like we have for DATE in Oracle like SYSDATE ) that I can use to get the weekly data.

I am trying to automate this process with the Data scheduler and am trying to remove the step for manually changing the dates everyweek.

I will really appreciate any replies in this regards.

Thanks
Raj

Posted: Wed Aug 25, 2004 1:55 pm
by gh_amitava
Hi,

You can use the query like this

select * from <table name> where <date> between current date -7 days and Current date;

Regards
Amitava