View previous topic :: View next topic
|
Author |
Message |
vardhan0007
New User
Joined: 05 Jun 2006 Posts: 51 Location: Bangalore,India
|
|
|
|
Hi,
I have to write one SQL query to delete some records based on below condition
I have to check the date field in the table which contains time stamp also but i have to match that field to current date if the date(time stamp) in table is lesser than 6 months i have to delete the record from table. This requirement has to achieve thru JCL only.
Thanks in advance.
Harsha. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
You can not do it just using JCL!
If you are sure you want to delete rows that are less than 6 months old then this sql statement will do it
DELETE FROM TABLE WHERE CURRENT TIMESTAMP - DATE_COL < 600000000;
For more than 6 months old change the < to >. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
DB2 date functions should let you do this for more readability
WHERE DATE_COL < CURRENT TIMESTAMP - 6 MONTHS |
|
Back to top |
|
|
|