View previous topic :: View next topic
|
Author |
Message |
Nethraa
New User
Joined: 02 Feb 2010 Posts: 16 Location: chennai
|
|
|
|
Hi All,
I need to write the records into file if the Expiration Date is <= 60 days.
I am calculating the date by Subtracting the current Date from End Date as follows.
COMPUTE WS-DIFF-DT-DD = WS-END-DT-DD - W-SYSDATE-DD
COMPUTE WS-DIFF-DT-MM = WS-END-DT-MM - W-SYSDATE-MM
COMPUTE WS-DIFF-DT-YY = WS-END-DT-YY - W-SYSDATE-YY
IF WS-DIFF-DT-DD < 60 AND WS-DIFF-DT-MM <= 2 AND
WS-DIFF-DT-YY = 0
Then WRITE THE RECORD.
Is that correct. If i am writing the condition wrongly could you please suggest me correct it? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
you should use the LE callable routines to calculate the difference between two dates.
your logic sucks. e.g. sysdate-dd is 10 and the end-dt-dd is 8
why would a ws-diff-dt-dd ever be more than 60?
suggest you provide a better explanation. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Quote: |
Dick said "your logic sucks."
|
Good to have you back....
Regards,
Bill |
|
Back to top |
|
|
Ranjithkumar
New User
Joined: 10 Sep 2008 Posts: 93 Location: India
|
|
|
|
Nethra
Convert the date from Gregorian(yymmdd) to Julian(yyddd) format and now you can easily find the difference b/w yy and ddd of W-SYSDATE & WS-END-DT. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
Hi Nethraa,
Just to be on the same page, could you explain your requirement better.
Quote: |
I need to write the records into file if the Expiration Date is <= 60 days. |
How can we compare date to no. of days ?
Quote: |
IF WS-DIFF-DT-DD < 60 AND WS-DIFF-DT-MM <= 2 AND WS-DIFF-DT-YY = 0 |
Again, just to be sure.... From my experience I have seen the expiry date used in such a way that when the differnece between the current date and the expiry date is more than 30 or 60 days, write to a archive file. so are u sure what you have mentioned is correct....
Pardon me for my curiosity... |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
dbzTHEdinosauer wrote: |
your logic sucks |
If there were an award in this category, this would be a good candidate!
Nethraa,
Use the INTEGER-OF-DATE and DATE-OF-INTEGER functions, maybe. |
|
Back to top |
|
|
Ragav86
New User
Joined: 27 Jan 2010 Posts: 37 Location: chennai
|
|
|
|
try this
COMPUTE X = FUNCTION INTEGER-OF-DATE(END-DATE)-
FUNCTION INTEGER-OF-DATE(SYSDATE)
IF X < 60
WRITE THE RECORD.
the format should be in YYYYMMDD |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Convert the date from Gregorian(yymmdd) to Julian(yyddd) format and now you can easily find the difference b/w yy and ddd of W-SYSDATE & WS-END-DT. |
previous Dick comment applies
10 jan 2010 - 25 dec 2009 ==> 650 days
10010 - 09360 ..... |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Use the Language Environment date functions to convert to and from Lilian day number; do your computations with that. |
|
Back to top |
|
|
Nethraa
New User
Joined: 02 Feb 2010 Posts: 16 Location: chennai
|
|
|
|
Hi All,
Sorry for the delayed reply. As i went on long leave i couldn't reply.
I will work on the suggestions and come back. |
|
Back to top |
|
|
|