IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To find day of a date in the past


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Sun Jun 08, 2014 8:53 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sun Jun 08, 2014 9:33 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Jun 09, 2014 2:43 pm
Reply with quote

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
View user's profile Send private message
Agni

New User


Joined: 22 Nov 2007
Posts: 83
Location: Chennai

PostPosted: Mon Jun 09, 2014 11:45 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
Search our Forums:

Back to Top