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
 

 

Converting date in format 25DEC10 to 2010/12/25

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
sagarnsydney

New User


Joined: 12 Dec 2008
Posts: 16
Location: sydney

PostPosted: Thu Dec 30, 2010 7:47 am    Post subject: Converting date in format 25DEC10 to 2010/12/25
Reply with quote

I have a requirement to convert date from the format 25DEC10 to 2010/12/25.

Regards,
Sagar
Back to top
View user's profile Send private message

Guest







PostPosted: Thu Dec 30, 2010 10:39 am    Post subject:
Reply with quote

Hi Sagar,
I have come up with this solution:
Code:

//SORTIN   DD *                                               
25DEC10                                                       
//SORTOUT     DD SYSOUT=*                                     
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=(3,3,CH,EQ,C'JAN'),OVERLAY=(8:C'20',6,2, 
                C'/01/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'FEB'),OVERLAY=(8:C'20',6,2, 
                C'/02/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'MAR'),OVERLAY=(8:C'20',6,2, 
                C'/03/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'APR'),OVERLAY=(8:C'20',6,2, 
                C'/04/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'MAY'),OVERLAY=(8:C'20',6,2, 
                C'/05/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'JUN'),OVERLAY=(8:C'20',6,2, 
                C'/06/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'JUL'),OVERLAY=(8:C'20',6,2, 
                C'/07/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'AUG'),OVERLAY=(8:C'20',6,2, 
                C'/08/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'SEP'),OVERLAY=(8:C'20',6,2, 
                C'/09/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'OCT'),OVERLAY=(8:C'20',6,2, 
                C'/10/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'NOV'),OVERLAY=(8:C'20',6,2, 
                C'/11/',1,2)),                                 
        IFTHEN=(WHEN=(3,3,CH,EQ,C'DEC'),OVERLAY=(8:C'20',6,2, 
                C'/12/',1,2))                                 
  OUTREC BUILD=(8,10)                                         
/*                                                             


Assumption: Year after 2000.

Devil13
There definitely is a better solution
Back to top
sagarnsydney

New User


Joined: 12 Dec 2008
Posts: 16
Location: sydney

PostPosted: Tue Jan 04, 2011 7:18 am    Post subject:
Reply with quote

Hi devil13,

Thanks for quick response. Is there any other way using date predefined functions in SORT to achieve the result....

Sagar
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Jan 05, 2011 12:54 am    Post subject: Reply to: Converting date in format 25DEC10 to 2010/12/25
Reply with quote

sagarnsydney,

There are no built-in functions to convert the date in text form. Here is another way of getting the desired results which also performs a date validity check.

Code:

//STEP0100 EXEC PGM=SORT                                     
//SYSOUT   DD SYSOUT=*                                       
//SORTIN   DD *                                             
25DEC10                                                     
//SORTOUT  DD SYSOUT=*                                       
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                           
  INREC IFOUTLEN=80,                                         
  IFTHEN=(WHEN=INIT,OVERLAY=(81:3,3,1,2,6,2)),               
  IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=81,                   
          INOUT=(C'JAN',C'01',C'FEB',C'02',C'MAR',C'03',     
                 C'APR',C'04',C'MAY',C'05',C'JUN',C'06',     
                 C'JUL',C'07',C'AUG',C'08',C'SEP',C'09',     
                 C'OCT',C'10',C'NOV',C'11',C'DEC',C'12'))), 
  IFTHEN=(WHEN=INIT,OVERLAY=(81,6,Y2W,TOGREG=Y4T(/)))       
//*
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm
No new posts LISTIDR compiled date/time jerryte IBM Tools 3 Thu Apr 20, 2017 7:37 pm
No new posts SUBSTR for Date functions Shaheen Shaik DB2 4 Thu Apr 06, 2017 2:14 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm


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