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
 

 

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

New User


Joined: 29 Jun 2005
Posts: 86

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: 1738
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: 1529
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: 1717
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: 1529
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: 1717
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: 1529
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: 1717
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: 2019
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

New User


Joined: 29 Jun 2005
Posts: 86

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 What is the command to check MODE of ... rohanthengal CLIST & REXX 6 Fri Nov 18, 2016 1:48 pm
No new posts TOT & DATE parameter in ICEMAN hemanthj642 DFSORT/ICETOOL 4 Mon Nov 14, 2016 5:19 am
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm


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