Page 1 of 2

How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 12:55 pm
by abi1008003
Hi ,

I am new to REXX code,Here i want to retrieve yesterday's date in rexx code

i am using below code :

/*Rexx*/
/*example cuurent date is 20190508*/
a = date('s') - 1
say a
/*returns 20190507 */

The above scenario working fine for all the date expect on date '20190501'.when its coming on 1st date (20190501) then its not giving 20190430 but it returns '20190500'

can anyone please help me to resolve this issue?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 1:40 pm
by expat

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:00 pm
by enrico-sorichetti
say date('s',(date('b')-1),'b')

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:20 pm
by abi1008003
Thanks for reply,

can we able to pass explicit date here?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:25 pm
by enrico-sorichetti
what do You mean by explicit date ?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:30 pm
by abi1008003
say example, now i want to check for date 1st(2019/05/01).How can i pass this date here and check?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:36 pm
by NicC
Check what? Describe what you want to do - fully.
Have you actually read the documentation, pointed to by expat, and understood it?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:41 pm
by abi1008003
i have mentioned clearly in the description
"The above scenario working fine for all the date expect on date '20190501'.when its coming on 1st date (20190501) then its not giving 20190430 but it returns '20190500'"

i cant change my Mainframe date so i want to pass this date '20190501' and verify whether its subtracting and giving result as before the date '20190430'
Hope you understand now!

Yes, i have read the documentation also,thats not working as expected!

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 2:54 pm
by abi1008003
you mean to say that we cant pass date here?

Re: How to retrieve yesterdays date in rexx code?

PostPosted: Wed May 08, 2019 3:01 pm
by enrico-sorichetti
Yes, i have read the documentation also,thats not working as expected!

unfortunately the documentation is right
YOUR EXPECTATIONS ARE WRONG !

You can pass explicit data of any kind as long as the format agrees with the operation and/or called function specifications

from the snippet You posted initially ...

date( 's' ) returns the SORTED date YYYYMMDD

which by REXX standars is a number

date('s')-1 is the same as 20190501 - 1 which gives 20190500

for an explicit date You will have to do a double jump ...
convert it to the base date
carry on all the date increment/decrement
convert it back to the format required

say date('s',(date('b','20190501','s')-1),'b')