Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Decscribe this REXX Date Function

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
abhijit.nayak01

Active User


Joined: 22 Mar 2009
Posts: 157
Location: South Africa

PostPosted: Mon Nov 09, 2009 11:46 pm    Post subject: Decscribe this REXX Date Function
Reply with quote

Can you please describe the below line:

d = date("S",(date("B",year||right(month,2,"0")||"01","S")-1) ,"B")

Thanks,
Abhijit.
Back to top
View user's profile Send private message

prino

Active Member


Joined: 07 Feb 2009
Posts: 989
Location: Oostende, Belgium

PostPosted: Tue Nov 10, 2009 12:39 am    Post subject:
Reply with quote

Why don't you rewrite it yourself as two different calls to date and trace it? Holy sith, it would have taken you less time to try it than to post this question.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10210
Location: italy

PostPosted: Tue Nov 10, 2009 1:03 am    Post subject: Reply to: Decscribe this REXX Date Function
Reply with quote

/good mood on

the statement gets the last day of the previous month

the syntax of the date function is in general ( metalanguage )

<output_date> = DATE(<output_date_format>,<input_date>, <input_date_format>)

S-format YYYYMMDD
B_format number of days since jan 01 0001

given the premises lets do some backward substitution
( d = date of the last day of the previous mont)

Code:
year = <some year>
month = <current month>
-- build the current month S date YYYYMM01
d_3 = year || right(month,2,"0") || "01"
-- convert to base format
d_2 = date("B",d_3,"S")
-- subtract one to get the last day of the previous month
d_1 = d_2 - 1
-- convert to S-format
d = date("S", d_1,"B")
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Tue Nov 10, 2009 4:41 am    Post subject:
Reply with quote

I'm glad I didn't see a /good mood off tag icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Nov 10, 2009 5:04 am    Post subject:
Reply with quote

Abhijit,

a couple hints for future code 'dis-assembly'.

1. REXX is similar to fortran in that you can have a single statement that contains umteen number of functions.

2. Open parenthesis '(' and closed parenthesis ')' ALLWAYS come in pairs. you never have an unequal number of parenthesis within a statement.

3. start with the innermost function/command and work outwards.

4. familiarize yourself with all the REXX most of the time you can differentiate a variable from a 'command'.

That was how Enrico was able to determine YEAR and MONTH

I would also memorize REXX general concepts

When in doubt, run a REXX Script to debug (TRACE) a statement.
Does not require a batch job, you can run them in your tso session.

/good mood off (for Mbabu)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts REXX DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us