How to retrieve yesterdays date in rexx code?



IBM's Command List programming language & Restructured Extended Executor

How to retrieve yesterdays date in rexx code?

Postby abi1008003 » Wed May 08, 2019 12:55 pm

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?
abi1008003
 
Posts: 5
Joined: Wed May 08, 2019 12:47 pm
Has thanked: 1 time
Been thanked: 0 time

Re: How to retrieve yesterdays date in rexx code?

Postby expat » Wed May 08, 2019 1:40 pm

expat
 
Posts: 459
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 8 times

Re: How to retrieve yesterdays date in rexx code?

Postby enrico-sorichetti » Wed May 08, 2019 2:00 pm

say date('s',(date('b')-1),'b')
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort

These users thanked the author enrico-sorichetti for the post:
abi1008003 (Wed May 08, 2019 2:20 pm)
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to retrieve yesterdays date in rexx code?

Postby abi1008003 » Wed May 08, 2019 2:20 pm

Thanks for reply,

can we able to pass explicit date here?
abi1008003
 
Posts: 5
Joined: Wed May 08, 2019 12:47 pm
Has thanked: 1 time
Been thanked: 0 time

Re: How to retrieve yesterdays date in rexx code?

Postby enrico-sorichetti » Wed May 08, 2019 2:25 pm

what do You mean by explicit date ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: How to retrieve yesterdays date in rexx code?

Postby abi1008003 » Wed May 08, 2019 2:30 pm

say example, now i want to check for date 1st(2019/05/01).How can i pass this date here and check?
abi1008003
 
Posts: 5
Joined: Wed May 08, 2019 12:47 pm
Has thanked: 1 time
Been thanked: 0 time

Re: How to retrieve yesterdays date in rexx code?

Postby NicC » Wed May 08, 2019 2:36 pm

Check what? Describe what you want to do - fully.
Have you actually read the documentation, pointed to by expat, and understood it?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: How to retrieve yesterdays date in rexx code?

Postby abi1008003 » Wed May 08, 2019 2:41 pm

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!
abi1008003
 
Posts: 5
Joined: Wed May 08, 2019 12:47 pm
Has thanked: 1 time
Been thanked: 0 time

Re: How to retrieve yesterdays date in rexx code?

Postby abi1008003 » Wed May 08, 2019 2:54 pm

you mean to say that we cant pass date here?
abi1008003
 
Posts: 5
Joined: Wed May 08, 2019 12:47 pm
Has thanked: 1 time
Been thanked: 0 time

Re: How to retrieve yesterdays date in rexx code?

Postby enrico-sorichetti » Wed May 08, 2019 3:01 pm

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')
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post