MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Date Difference using REXX

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
RajSanj
Beginner


Joined: 17 Mar 2006
Posts: 15
Topics: 7

PostPosted: Wed May 24, 2006 12:16 pm    Post subject: Date Difference using REXX Reply with quote

Hi,

I have 2 dates in a utility developed using REXX. I need to find out what is the difference in these 2 dates.

Do we have a function that calculates the difference?

Regards,
RajSanj
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Wed May 24, 2006 12:45 pm    Post subject: Reply with quote

RajSanj,

Please post your questions in the approriate forum.

Code:

/* REXX */
DAYDIFF = DATE('B', 'CCYYMMDD', 'S') - DATE('B', 'CCYYMMDD', 'S')
SAY 'DAYS DIFFERENCE    : ' DAYDIFF


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
RajSanj
Beginner


Joined: 17 Mar 2006
Posts: 15
Topics: 7

PostPosted: Wed May 24, 2006 4:39 pm    Post subject: Reply with quote

Thanks alot Kolusu it works.
Back to top
View user's profile Send private message
pradmenon
Beginner


Joined: 07 Apr 2006
Posts: 6
Topics: 1
Location: INDIA

PostPosted: Sun Sep 03, 2006 11:04 pm    Post subject: Reply with quote

I have a list of some dates in a sequential file. I am trying to write a Rexx program to do some specific action based on the difference between each of those dates & today's date. I am reading in the dates from the external file into the program as variables. I tried the DATE function in Rexx to calculate the difference, but I am getting the "Incorrect call to routine" error, probably because I am using a variable inside the DATE function. Is there a way to specify variable name inside the DATE function, instead of giving an actual date?
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Mon Sep 04, 2006 12:29 am    Post subject: Reply with quote

You can always use a variable. The format of the data in your variable is incorrect
Back to top
View user's profile Send private message Visit poster's website
pradmenon
Beginner


Joined: 07 Apr 2006
Posts: 6
Topics: 1
Location: INDIA

PostPosted: Mon Sep 04, 2006 12:46 pm    Post subject: Reply with quote

The format of dates I have in my external file is S. One of the dates for example is 20060914. This is the portion of code that I have.
Code:

ADDRESS TSO "EXECIO * DISKR INFILE (STEM VAR1."
I = 1
DO WHILE I <= VAR1.0                   
   PARSE VAR VAR1.I CAPDATE
   SAY CAPDATE                         
   CAPDATE = SPACE(CAPDATE,0)           

   CDATE = DATE('B',CAPDATE,'S')       
   VOLDAT = CDATE - 42                 
   SAY VOLDAT
   TDATE = DATE(B)       
   IF TDATE = VOLDAT THEN
     .... /* some specific processing */
   ELSE
     NOP
   I = I + 1
END

I also tried putting the variable in quotes, like
CDATE = DATE('B',"'"CAPDATE"'",'S')
but it still gives the same error. I am at loss what I am doing wrong.
Back to top
View user's profile Send private message
acevedo
Beginner


Joined: 03 Dec 2002
Posts: 127
Topics: 0
Location: Europe

PostPosted: Tue Sep 05, 2006 1:09 am    Post subject: Reply with quote

what about posting the CAPDATE value when you get the error?
Back to top
View user's profile Send private message
pradmenon
Beginner


Joined: 07 Apr 2006
Posts: 6
Topics: 1
Location: INDIA

PostPosted: Tue Sep 05, 2006 6:29 am    Post subject: Reply with quote

The value I am getting in CAPDATE is in the expected format. The Rexx goes down in the line CDATE = DATE('B',"'"CAPDATE"'",'S').
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Sep 05, 2006 9:25 am    Post subject: Reply with quote

Why are you adding quotes to the value you are sending to the date function? No date values have quotes in them
Back to top
View user's profile Send private message Visit poster's website
pradmenon
Beginner


Joined: 07 Apr 2006
Posts: 6
Topics: 1
Location: INDIA

PostPosted: Tue Sep 05, 2006 10:03 am    Post subject: Reply with quote

Ohhh... ok. The examples I saw in help for the DATE function had quotes around the dates. And it worked when I gave the actual dates instead of the variable. So, I thought the quotes are supposed to be there. Evidently not!! Thanks, semigeezer. Smile
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Tue Sep 05, 2006 11:04 am    Post subject: Reply with quote

No problem. If there is any question that comes up about rexx syntax, it is almost always about quotes. It is easy to understand once you understand it (circular logic there), but it is different than some languages.
Back to top
View user's profile Send private message Visit poster's website
acevedo
Beginner


Joined: 03 Dec 2002
Posts: 127
Topics: 0
Location: Europe

PostPosted: Wed Sep 06, 2006 4:04 am    Post subject: Reply with quote

but in the first portion of the code you were using:
Code:

 CDATE = DATE('B',CAPDATE,'S') 


I mean, without quotes, and you said you were getting the same error.... ???
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group