View previous topic :: View next topic |
Author |
Message |
pulsar Beginner
Joined: 09 May 2007 Posts: 10 Topics: 3
|
Posted: Tue Nov 27, 2007 7:26 am Post subject: Help:DB2-table updated ibn last three days |
|
|
Is it possible to write a query where i can fetch rows updated in last three days.
Eg:
Select Val1 from Table1 where
last updated date > current date - 3
Note:
Last updated date is a column in table.
[/code] |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Tue Nov 27, 2007 7:36 am Post subject: |
|
|
Yes
WHERE LAST_UPDATED_DATE > CURRENT DATE - 3 DAYS |
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Tue Nov 27, 2007 7:41 am Post subject: |
|
|
Pulsar,
Yes you can. You can directly pass the value too like
WHERE LAST_UPDATED_DATE > '11.24.2007' |
|
Back to top |
|
 |
pulsar Beginner
Joined: 09 May 2007 Posts: 10 Topics: 3
|
Posted: Tue Nov 27, 2007 8:22 am Post subject: |
|
|
Thanks CraigG & vkphani.
But now the problem is getting the Current date. how can i get it for any table? |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Tue Nov 27, 2007 8:27 am Post subject: |
|
|
pulsar wrote: | Thanks CraigG & vkphani.
But now the problem is getting the Current date. how can i get it for any table? |
It's right here
Code: | WHERE LAST_UPDATED_DATE > CURRENT DATE - 3 DAYS |
or maybe CURRENT_DATE, it is a DB2 special register. |
|
Back to top |
|
 |
pulsar Beginner
Joined: 09 May 2007 Posts: 10 Topics: 3
|
Posted: Tue Nov 27, 2007 8:33 am Post subject: |
|
|
thanks CraigG.
I got it using
Code: |
SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1
|
|
|
Back to top |
|
 |
jim haire Beginner
Joined: 30 Dec 2002 Posts: 140 Topics: 40
|
Posted: Wed Nov 28, 2007 12:32 pm Post subject: |
|
|
Pulsar,
You shouldn't need to get the CURRENT DATE from any table. As Craig G. mentioned it's in a special register. Just by referencing it in your SQL it should know what the value of CURRENT DATE is. |
|
Back to top |
|
 |
|
|