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

Date comparison


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

New User


Joined: 07 Feb 2007
Posts: 27
Location: chennai

PostPosted: Tue Mar 27, 2012 3:46 pm
Reply with quote

Hi ,

I need to compare the two dates of the given input files but the date format is DDMMMYYYY , so is there any way to convert MMM to numeric

Example
21MAR2012 - 21032012
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Mar 27, 2012 3:54 pm
Reply with quote

since a date in the format of day/mo/year can only be compared as equal or not equal,

you are sorta wasting your time.

don't you really want to compare year/mo/da?

and since there are only 12 months,
either use a 'built by you' lookup cobol internal table
or use a 12 step EVALUATE.

why would you want to call a service to provide you potentially 12 returns?
Back to top
View user's profile Send private message
arunmozhicholan

New User


Joined: 07 Feb 2007
Posts: 27
Location: chennai

PostPosted: Tue Mar 27, 2012 4:13 pm
Reply with quote

Thanks ,

I can use Evaluate to get the results .
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Mar 27, 2012 4:20 pm
Reply with quote

A fun way to do it is to always design so you have a usable date on the files (yyyymmdd or yyyyddd) and then do necessary manipulation for "other" purposes. Can always sort, always compare.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Mar 27, 2012 8:21 pm
Reply with quote

Use the Language Environment CEEDAYS function to get Lilian day number, and then use it as you see fit.
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: Tue Mar 27, 2012 11:21 pm
Reply with quote

Akatsukami's suggestion is a much better way to go.

If you haven't validated the date beforehand, COBOL DATE FUNCTION's will crash and burn if a bad-date is passed.

LE Callable Service routines will return X'0000' or non-X'0000' in the first 2-Bytes of the Feedback code, to signify a valid or invalid date, respectively.

What if you had a February 29 day and it wasn't a valid leap year and you're using FUNCTION's?

You never get used to those O'Dark Thirty phone calls and in this case, they're preventable.... icon_wink.gif
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 Need to convert date format DFSORT/ICETOOL 20
No new posts Need help to append a date&tsp at... DFSORT/ICETOOL 9
No new posts Fetch data from programs execute (dat... DB2 3
Search our Forums:

Back to Top