View previous topic :: View next topic
|
Author |
Message |
anand tr
New User
Joined: 12 Aug 2008 Posts: 41 Location: chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Can you use a COBOL IF statement? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What formats are the dates in? Without some information all we can do is guess. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
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 |
|
|
anand tr
New User
Joined: 12 Aug 2008 Posts: 41 Location: chennai
|
|
|
|
thank u all; that help me a lot.. |
|
Back to top |
|
|
senjay
Active User
Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 ) |
|
Back to top |
|
|
senjay
Active User
Joined: 10 May 2007 Posts: 147 Location: India
|
|
|
|
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 |
|
|
|