abhijit.nayak01 Active User Joined: 22 Mar 2009 Posts: 157 Location: South Africa
Can you please describe the below line:
d = date("S",(date("B",year||right(month,2,"0")||"01","S")-1) ,"B")
prino Senior Member Joined: 07 Feb 2009 Posts: 1074 Location: Oostende, Belgium
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.
enrico-sorichetti Global Moderator Joined: 14 Mar 2007 Posts: 10396 Location: italy
/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>)
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)
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")
MBabu Active User Joined: 03 Aug 2008 Posts: 401 Location: Mumbai
I'm glad I didn't see a /good mood off tag
dbzTHEdinosauer Global Moderator Joined: 20 Oct 2006 Posts: 6970 Location: porcelain throne
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 a statement.
Does not require a batch job, you can run them in your tso session.
/good mood off (for Mbabu)
All times are GMT + 6 Hours