arunkumar_e Beginner
Joined: 06 May 2004 Posts: 27 Topics: 16 Location: Bangalore
|
Posted: Wed Mar 30, 2005 11:58 pm Post subject: Need utility to change dates in a file |
|
|
Hi
I have a file say FILE1 where in i have 2 dates say STARTDATE and ENDDATE.
Suppose i change the dates this saturday , it wud be like
'04022004 04022005'
Suppose i change the dates next saturday , it wud be like
'04092004 04092005'
and so on.
I also have a query in a PDS which uses these STARTDATE and ENDDATE to extract the data from tables.Now every week i change these
DATES in the FILE1 and run the querry.
Now i want to automate this process. say i want a utility which wud convert the STARTDATE and ENDDATE. Also i want to run the utility
every week end say every saturday.
The STARTDATE and ENDDATE are of the format MMDDYYYY.
can any one help me out in this
Thanks
Arun _________________ Arun
"Genius is one percent inspiration and ninety-nine percent perspiration." -- Thomas A. Edison |
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Thu Mar 31, 2005 6:39 am Post subject: |
|
|
arunkumar_e,
try this sql. This will bring the saturday's date of this year as start date and adds 1 year to it as end date.
Code: |
SELECT SUBSTR(CHAR(NEXT_DAY(CURRENT DATE,'SAT')),6,2)
CONCAT
SUBSTR(CHAR(NEXT_DAY(CURRENT DATE,'SAT')),9,2)
CONCAT
SUBSTR(CHAR(NEXT_DAY(CURRENT DATE,'SAT')),1,4)
,SUBSTR(CHAR(DATE(NEXT_DAY(CURRENT DATE,'SAT')) + 1 YEAR),6,2)
CONCAT
SUBSTR(CHAR(DATE(NEXT_DAY(CURRENT DATE,'SAT')) + 1 YEAR),9,2)
CONCAT
SUBSTR(CHAR(DATE(NEXT_DAY(CURRENT DATE,'SAT')) + 1 YEAR),1,4)
FROM SYSIBM.SYSDUMMY1
;
|
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|