Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
REXX to format the date

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

Active User


Joined: 29 Jun 2005
Posts: 118

PostPosted: Thu Jul 05, 2012 5:56 pm    Post subject: REXX to format the date
Reply with quote

Hi ,

Iam New to REXX and i have a question on formating the date .

My input date value will be like "201207"

output should be like "July2012".

Iam also refering the manuals to get it from that , if any one could help me out it would be great help for me.

Thanks
Balaji K
Back to top
View user's profile Send private message

Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1782
Location: Bloomington, IL

PostPosted: Thu Jul 05, 2012 6:06 pm    Post subject:
Reply with quote

It'll be a little while before I can test; however, this code fragment should get you started:
Code:
input_date = input_date || "01"
year = substr(input_date,1,4)
output_date = date(,input_date,"Month")
output_date = output_date || year
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Thu Jul 05, 2012 6:40 pm    Post subject:
Reply with quote

Modified Akatsukami's code

Code:

INPUT_DATE  = "201207"
OUTPUT_DATE = SUBSTR(INPUT_DATE,5,2)|| "/" || "01" || "/" || ,
              SUBSTR(INPUT_DATE,3,2)
OUTPUT_DATE = DATE('M',OUTPUT_DATE,'USA')
OUTPUT_DATE = OUTPUT_DATE || SUBSTR(INPUT_DATE,1,4)
SAY OUTPUT_DATE
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1922
Location: UK

PostPosted: Thu Jul 05, 2012 7:54 pm    Post subject:
Reply with quote

You could also look at using the Date builtin to convert from one date format to the other. Or, much more simply, have a stem with the month abbrevaitions, extract the month number from the date and use that as in index into the stem. To go the other way you can have a stem of month numbers indexed by the month NAME.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Thu Jul 05, 2012 8:02 pm    Post subject:
Reply with quote

Nic Clouston wrote:
To go the other way you can have a stem of month numbers indexed by the month NAME.


Seems to be best solution out of all "Atleast for me"
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1922
Location: UK

PostPosted: Thu Jul 05, 2012 10:19 pm    Post subject:
Reply with quote

but I have forgotten the syntax - I will have to look for a bit of code that was probably written in australia and, therefore, is 16 years old - at least
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Thu Jul 05, 2012 10:29 pm    Post subject:
Reply with quote

Nah that wont be needed I will do it fot you

Code:
Mon.01="January"
.
.
Mon.12="December"
In_date ="201207"
I=SUBSTR(IN_DATE,5,2)
OUT_DATE=MON.I||SUBSTR(IN_DATE,1,4)
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1922
Location: UK

PostPosted: Fri Jul 06, 2012 2:26 am    Post subject:
Reply with quote

Oh - that is dead simple. I was referring to the fact that I need to check the syntax for accessing the stem by using a 'string' as the key sort of like:
Code:

m.jan = 1
m.feb = 2
:
m.dec = 12

monthnum= m.jan

should shove 1 into monthnum but I have not got the syntax quite right and I don't have my work USB plugged in.
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Fri Jul 06, 2012 4:14 am    Post subject: Reply to: REXX to format the date
Reply with quote

If I understand this tread correctly, the code:
Code:
m.jan = 1
m.feb = 2
:
m.dec = 12


is a tangent and not particularly useful to solve the OP's problem.
Back to top
View user's profile Send private message
Peter Nancollis

New User


Joined: 15 Mar 2011
Posts: 47
Location: UK

PostPosted: Fri Jul 06, 2012 6:29 am    Post subject:
Reply with quote

Code:

/*  No stems No substrings .... just for laughs
     Not right/wrong/better   just different   [and not tested ]
*/
Months='January February ... December'
mm=right(in_date,2)
yy=left(in_date,4)
answer=word(months,mm)||yy

Back to top
View user's profile Send private message
balaji81_k

Active User


Joined: 29 Jun 2005
Posts: 118

PostPosted: Fri Jul 06, 2012 10:41 am    Post subject: Reply to: REXX to format the date
Reply with quote

Many Thanks to Every one !!!!!!!!!!!!!!

who shared for this topic .. i put the code as suggested it working fine.


Thanks
Balaji K icon_biggrin.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Fri Jul 06, 2012 11:32 am    Post subject:
Reply with quote

Peter Nancollis

Exactly the same method I have used in the past - good shout
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
No new posts Rexx to send an email without SMTP Se... upendrasri All Other Mainframe Topics 4 Sun Nov 19, 2017 7:59 pm
No new posts ISREDIT Macro is not returning back t... nico_neoz CLIST & REXX 17 Sat Nov 18, 2017 7:40 pm
No new posts REXX LISTDSI () SMSINFO is not working upendrasri CLIST & REXX 4 Fri Nov 17, 2017 11:33 am
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 4 Wed Nov 15, 2017 4:27 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us