IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Regarding DATE command in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Aug 07, 2009 2:14 pm
Reply with quote

Is there any solution for getting the month number from the DATE command in REXX.
i have tried using this function
Code:
CURRENT_MONTH = SUBSTR(DATE('U'),1,2) 
        which would return '08' 


but if i give the month name as REL=OCT im unable to get the month number
Code:
MONTH = SUBSTR(DATE('U','01 'REL' 2009,1,2)  This is returning me an error Incorrect call to routine


as i have gone through the DATE function
it suggests me to use in the manner
Code:
  DATE('U','01 Oct 2009') gives me result '10/01/09'
   but   DATE('U','01 OCT 2009') gives me incorrect result


is there any function in rexx to get OCT in camel notation so i would be solved my problem
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Aug 07, 2009 2:54 pm
Reply with quote

Set up a stem,

Code:
camel.0JAN = 'Jan'
.
.
.
camel.0DEC = 'Dec'


and use the value function to get the 'camel'ised month. And RTFM so that you don't have to come back to ask how to use the value function!
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Fri Aug 07, 2009 3:03 pm
Reply with quote

let me put the question in this way,
is there any function which would return the month number
if we provide the first three chars of a month.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Aug 07, 2009 3:13 pm
Reply with quote

NO

But it's not difficult to do it yourself is it. It took me about 3 minutes to code this up, although Prino beat me to it with an alternative.

All you need to do is to put the code in a concatenated library and change it a little to make it a called module.
Code:

DATEIN = "01 APR 2009"                   
PARSE VAR DATEIN DD MM YY               
IF LEFT(DD,1) = '0' THEN DD = RIGHT(DD,1)
SELECT                                   
   WHEN MM = 'JAN' then MM = 'Jan'       
   WHEN MM = 'FEB' then MM = 'Feb'       
   WHEN MM = 'MAR' then MM = 'Mar'       
   WHEN MM = 'APR' then MM = 'Apr'       
   WHEN MM = 'MAY' then MM = 'May'       
   WHEN MM = 'JUN' then MM = 'Jun'       
   WHEN MM = 'JLY' then MM = 'Jly'       
   WHEN MM = 'AUG' then MM = 'Aug'       
   WHEN MM = 'SEP' then MM = 'Sep'       
   WHEN MM = 'OCT' then MM = 'Oct'       
   WHEN MM = 'NOV' then MM = 'Nov'       
   WHEN MM = 'DEC' then MM = 'Dec'       
   OTHERWISE NOP                         
END                                     
MTH = SUBSTR(DATE('U',DD MM YY,'N'),1,2)
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Fri Aug 07, 2009 9:48 pm
Reply with quote

This just seems like a case situation. As long as you know what case the date function needs, program for it.
Code:
parse var mm m1 2 m2                           
mm =          m1 || ,                           
    translate(m2,'abcdefghijklmnopqrstuvwxyz',,
                 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') 


ps. I am not sure if this any more elegant than the other solutions, but seems to be simpler to me.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Aug 07, 2009 9:56 pm
Reply with quote

since I am becoming like a picky old lady icon_biggrin.gif
here is how I would do it

Code:
datein  = "01 APR 2009"
parse var datein dd mm yy
mn = wordpos(translate(mm),"JAN FEB MAR APR MAY JUN JLY AUG SEP OCT NOV DEC")
say mn
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sat Aug 08, 2009 3:53 am
Reply with quote

Enrico, I do not think your code snippet answers the right problem. I thought the problem was that the DATE('U','01 OCT 2009') function failed because it wanted a mixed case month... Oct instead of OCT. At least, that is the way I read it, and also what the other posters seemed to solve.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Aug 08, 2009 12:45 pm
Reply with quote

Quote:
let me put the question in this way,
is there any function which would return the month number
if we provide the first three chars of a month.


it does, it does icon_biggrin.gif
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2547
Location: Silicon Valley

PostPosted: Sat Aug 08, 2009 10:30 pm
Reply with quote

Doh!

I stand corrected.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Aug 08, 2009 11:31 pm
Reply with quote

no need for that.. You can sit corrected icon_cool.gif
Back to top
View user's profile Send private message
tecnokrat
Warnings : 1

Active User


Joined: 22 May 2009
Posts: 160
Location: Bangalore

PostPosted: Mon Aug 10, 2009 10:46 am
Reply with quote

Thanks enrico,
for solving my problem in a simpler manner
icon_wink.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top