View previous topic :: View next topic
|
Author |
Message |
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Hi All,
I have a requirement in which I need to find the day of a date in the past.
In my COBOL program I will be using an input file which will be having account numbers. I need to read that account number and go in to an IMS DB to check the date. That date is the entry date of that account number in the system. Usually the date would be a past date. I have to take that date and find the date of last Friday of that month and also I have to find out the date of previous month's last Friday.
For example, if the entry date of an account number is 01012014 (DDMMYY format)in the database, I need to find out the date of last Friday of January 2014 and also if the job is going to run in July, I have to find out the date for last Friday of June 2014 as well.
Can someone please help me with this?
Also, please let me know if you need more details.
Regards
Agni |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
where are You facing problems ...
the logic or the coding ?
hint ...
the INTEGER-OF-DATE and DATE-OF-INTEGER are all You need ...
INTEGER-OF-DATE returns an absolute number whose modulo 7
will tell the week day
something like
Code: |
IDATE = FUNCTION INTEGER-OF-DATE (Your date)
DOFW = FUNCTION MOD( IDATE, 7)
IFRI = IDATE + 7 -DOFW
FRIDAY = FUNCTION DATE-OF-INTEGER(IFRI)
|
I SAID SOMETHING LIKE ...
what I posted just finds the friday of the same week of the input date
probably it would be faster
to find the FRIDAY before the first day of the month that follows |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Before using INTEGER-OF-DATE, validate "your date". If you don't have any type of date validity checking facility, then use the LE Callable Date routine "CEEDAYS".
After calling "CEEDAYS", if the first 2-bytes of the 12-byte Feedback area are NOT X'00's, then the date is invalid.
Search the forum for "CEEDAYS". You'll get many hits and suggestions.
Any type of DATE FUNCTION in COBOL (except for FUNCTION CURRENT-DATE) requires valid data. Otherwise, you'll crash and burn.
"CEEDAYS" is also handy to determine if a particular year is a leap-year. Just build the leap-year date (for example) as "YYYY0229" and pass it to "CEEDAYS". If the first 2-bytes of the feedback area are NOT X'00's, then it's not a leap-year.
HTH.... |
|
Back to top |
|
|
Agni
New User
Joined: 22 Nov 2007 Posts: 83 Location: Chennai
|
|
|
|
Bill O'Boyle wrote: |
Before using INTEGER-OF-DATE, validate "your date". If you don't have any type of date validity checking facility, then use the LE Callable Date routine "CEEDAYS".
After calling "CEEDAYS", if the first 2-bytes of the 12-byte Feedback area are NOT X'00's, then the date is invalid.
Search the forum for "CEEDAYS". You'll get many hits and suggestions.
Any type of DATE FUNCTION in COBOL (except for FUNCTION CURRENT-DATE) requires valid data. Otherwise, you'll crash and burn.
"CEEDAYS" is also handy to determine if a particular year is a leap-year. Just build the leap-year and pass it to "CEEDAYS". If the first 2-bytes of the feedback area are NOT X'00's, then it's not a leap-year.
HTH.... |
Hi Bill,
Sure, I will do that. Thanks for your suggestion.
Regards
Afni |
|
Back to top |
|
|
|