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

compare 2 dates in cobol.


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

New User


Joined: 12 Aug 2008
Posts: 41
Location: chennai

PostPosted: Wed Aug 27, 2008 2:39 pm
Reply with quote

can we compare two dates if they are of same format?.
assuming that the two dates are present in two different files and are seperated by common seperator.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Aug 27, 2008 5:03 pm
Reply with quote

Can you use a COBOL IF statement?
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Aug 27, 2008 6:36 pm
Reply with quote

Hi,
Quote:
can we compare two dates if they are of same format?.
Why would you ask this ? Were you able to compre two dates of different formats ?
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Aug 27, 2008 6:56 pm
Reply with quote

Quote:

are seperated by common seperator


by separater, do you mean a hypen (-) or / or something between year, month and day?

if the date is not 6 or 8 numbers, (without a separater) you are only going to be able to check for unequal or equal. less than or greater than will not work.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Aug 27, 2008 7:05 pm
Reply with quote

What formats are the dates in? Without some information all we can do is guess.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 28, 2008 10:31 am
Reply with quote

Hi you can use intrinsic function
Code:

COMPUTE WS-INT-DATE1 = FUNCTION INTEGER-OF-DATE (WS-DATE1).
COMPUTE WS-INT-DATE2 = FUNCTION INTEGER-OF-DATE (WS-DATE2).

IF (WS-INT-DATE1 - WS-INT-DATE2) = 0
DISPLAY "DATES ARE SAME"
END-IF.
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Thu Aug 28, 2008 10:58 am
Reply with quote

to use above you need dates in integer formats.
so you can convert it to numeric from alphanumeric removing separator.
You can use redefine clause or you can use function NUMVAL or you can directly move like

MOVE alpha-date(1:4) TO num-year(1:4).
Back to top
View user's profile Send private message
anand tr

New User


Joined: 12 Aug 2008
Posts: 41
Location: chennai

PostPosted: Tue Sep 02, 2008 11:38 am
Reply with quote

thank u all; that help me a lot..
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Thu Jan 06, 2011 2:36 pm
Reply with quote

Quote:

Can any one pls explain me how to compare two dates (dd.mm.yyyy).Inputs are given in the WS as values.


I am shocked to see this post. I am not the one who wrote the above post. Some one has entered in my Login details and posted this. Could any of you moderators, please delete the previous post that is made in my ID.
I will change my password to make sure it does not happen again.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jan 06, 2011 8:11 pm
Reply with quote

Hi Senjay,

The previous post from your id and the reply have been deleted.

As whoever used your id to post the question is quite likely one of your co-workers, you might encourage them to register an id of their own (if you are able to determine who icon_smile.gif )
Back to top
View user's profile Send private message
senjay

Active User


Joined: 10 May 2007
Posts: 147
Location: India

PostPosted: Fri Jan 07, 2011 10:47 am
Reply with quote

Hi Dick,

Yes, He/She should be my co-worker. I was asked this question by one of my co-workers and I pointed him to the manual and explained him how to do it before the post was made. What makes me constatntly worrying is, when many tend to raise 'do-it-for-me-query' in forums rather than looking in to the manuals. I have always been encouraging co-workers to read the manuals and constantly participate in mainframe forums, but I never expected that 'someone' would misuse my login details for raising such a simple query despite the topic was already having the answer.
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 Replace each space in cobol string wi... COBOL Programming 2
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top