View previous topic :: View next topic
|
Author |
Message |
rohanatl
New User
Joined: 21 Oct 2005 Posts: 22
|
|
|
|
HI All,
i want to retrieve the records from the db2 table where the condition is one month old from the date available in the table.
There is a field called date1 which will contain the date in which the records are inserted to the table,
i dont want to change the query every time,Can any one give me a query which will perform the same.
select * from Table name where date = one month old |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Hello,
You can try something like this.
Code: |
select * from Table name where date = current date - 30 days |
Thanks,
Arun |
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
Back to top |
|
|
murugan_mf
Active User
Joined: 31 Jan 2008 Posts: 148 Location: Chennai, India
|
|
|
|
can you try this,
Code: |
SELECT * FROM TBL_NAME WHERE DAYS(CURRENT DATE) - DAYS(DATE1) <= 30; |
|
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
There are months that have more or less than 30 days. The - 30 DAYS calculation is garbage from a pure calendar point of view. |
|
Back to top |
|
|
|