Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

compare 2 dates in cobol.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: compare 2 dates in cobol.
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: 8055
Location: East Dubuque, Illinois, USA

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

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

Senior Member


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

PostPosted: Wed Aug 27, 2008 6:36 pm    Post subject:
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: 6967
Location: porcelain throne

PostPosted: Wed Aug 27, 2008 6:56 pm    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject: Reply to: compare 2 dates in cobol.
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    Post subject: Reply to: compare 2 dates in cobol.
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

Site Director


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

PostPosted: Thu Jan 06, 2011 8:11 pm    Post subject:
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    Post subject: Reply to: compare 2 dates in cobol.
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts member list compare jzhardy TSO/ISPF 6 Fri May 12, 2017 3:18 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us