View previous topic :: View next topic |
Author |
Message |
RajSanj Beginner
Joined: 17 Mar 2006 Posts: 15 Topics: 7
|
Posted: Wed May 24, 2006 12:16 pm Post subject: Date Difference using REXX |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed May 24, 2006 12:45 pm Post subject: |
|
|
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 |
|
|
RajSanj Beginner
Joined: 17 Mar 2006 Posts: 15 Topics: 7
|
Posted: Wed May 24, 2006 4:39 pm Post subject: |
|
|
Thanks alot Kolusu it works. |
|
Back to top |
|
|
pradmenon Beginner
Joined: 07 Apr 2006 Posts: 6 Topics: 1 Location: INDIA
|
Posted: Sun Sep 03, 2006 11:04 pm Post subject: |
|
|
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 |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Mon Sep 04, 2006 12:29 am Post subject: |
|
|
You can always use a variable. The format of the data in your variable is incorrect |
|
Back to top |
|
|
pradmenon Beginner
Joined: 07 Apr 2006 Posts: 6 Topics: 1 Location: INDIA
|
Posted: Mon Sep 04, 2006 12:46 pm Post subject: |
|
|
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 |
|
|
acevedo Beginner
Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Tue Sep 05, 2006 1:09 am Post subject: |
|
|
what about posting the CAPDATE value when you get the error? |
|
Back to top |
|
|
pradmenon Beginner
Joined: 07 Apr 2006 Posts: 6 Topics: 1 Location: INDIA
|
Posted: Tue Sep 05, 2006 6:29 am Post subject: |
|
|
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 |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Tue Sep 05, 2006 9:25 am Post subject: |
|
|
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 |
|
|
pradmenon Beginner
Joined: 07 Apr 2006 Posts: 6 Topics: 1 Location: INDIA
|
Posted: Tue Sep 05, 2006 10:03 am Post subject: |
|
|
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. |
|
Back to top |
|
|
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Tue Sep 05, 2006 11:04 am Post subject: |
|
|
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 |
|
|
acevedo Beginner
Joined: 03 Dec 2002 Posts: 127 Topics: 0 Location: Europe
|
Posted: Wed Sep 06, 2006 4:04 am Post subject: |
|
|
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 |
|
|
|
|