MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help:DB2-table updated ibn last three days

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
pulsar
Beginner


Joined: 09 May 2007
Posts: 10
Topics: 3

PostPosted: Tue Nov 27, 2007 7:26 am    Post subject: Help:DB2-table updated ibn last three days Reply with quote

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
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Tue Nov 27, 2007 7:36 am    Post subject: Reply with quote

Yes

WHERE LAST_UPDATED_DATE > CURRENT DATE - 3 DAYS
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Tue Nov 27, 2007 7:41 am    Post subject: Reply with quote

Pulsar,

Yes you can. You can directly pass the value too like
WHERE LAST_UPDATED_DATE > '11.24.2007'
Back to top
View user's profile Send private message Send e-mail
pulsar
Beginner


Joined: 09 May 2007
Posts: 10
Topics: 3

PostPosted: Tue Nov 27, 2007 8:22 am    Post subject: Reply with quote

Thanks CraigG & vkphani.

But now the problem is getting the Current date. how can i get it for any table?
Back to top
View user's profile Send private message
CraigG
Intermediate


Joined: 02 May 2007
Posts: 202
Topics: 0
Location: Viginia, USA

PostPosted: Tue Nov 27, 2007 8:27 am    Post subject: Reply with quote

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
View user's profile Send private message
pulsar
Beginner


Joined: 09 May 2007
Posts: 10
Topics: 3

PostPosted: Tue Nov 27, 2007 8:33 am    Post subject: Reply with quote

thanks CraigG.

I got it using
Code:

SELECT CURRENT DATE FROM SYSIBM.SYSDUMMY1
Back to top
View user's profile Send private message
jim haire
Beginner


Joined: 30 Dec 2002
Posts: 140
Topics: 40

PostPosted: Wed Nov 28, 2007 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group