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
 

 

Convert Timestamp Value

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

New User


Joined: 23 Sep 2006
Posts: 21
Location: India

PostPosted: Thu May 05, 2016 6:01 pm    Post subject: Convert Timestamp Value
Reply with quote

Hi,

I have a requirement to convert a Datetime format into another timestamp format.

For Example

Input File:

Code:
Jun 12 2014  6:36:04:423AM
Oct 11 2013  9:49:00:826PM
Jan 12 2015 12:38:03:376PM
Jan 21 2015  4:54:08:743PM


Should get converted into as

Output File:

Code:
20140612063604423
20131011214900826
20150112123803376
20150121165408743


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

mrdinesh

New User


Joined: 23 Sep 2006
Posts: 21
Location: India

PostPosted: Thu May 05, 2016 6:03 pm    Post subject: Reply to: Convert Timestamp Value
Reply with quote

I tried searching through the forum for example but couldnot find anything relevant for this. I was thinking of using IFTHEN in condition in the OUTREC statement. Thought of checking if there are any other efficient methods are available.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri May 06, 2016 1:06 am    Post subject:
Reply with quote

Use inout to convert month to a number and then translate AM/PM by adding 12 to the hours except 12 and build as per output.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri May 06, 2016 5:29 pm    Post subject: Reply to: Convert Timestamp Value
Reply with quote

Most of what you want is simple rearranging. To change the months to numbers, look at CHANGE, which will be more effective than FINDREP with INOUT. For your PM you will need to add 12, with the output of ZD with a length of two, or use an EDIT (like TT).

The potential leading space in the hours can be changed to a '0' with another CHANGE, with a default for non-space of the original value.
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 158
Location: Chennai

PostPosted: Mon May 09, 2016 7:24 am    Post subject: Reply to: Convert Timestamp Value
Reply with quote

This code may help you.
Code:

OPTION COPY                                                     
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1,3,                           
                                 CHANGE=(3,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'),       
                                 NOMATCH=(C'00'))),             
IFTHEN=(WHEN=INIT,BUILD=(8,4,1,2,5,2,13,2,FS,ZD,16,2,19,2,22,3))
Back to top
View user's profile Send private message
magesh23586

Active User


Joined: 06 Jul 2009
Posts: 158
Location: Chennai

PostPosted: Mon May 09, 2016 8:18 am    Post subject: Reply to: Convert Timestamp Value
Reply with quote

Missed +12 addition.

Code:

OPTION COPY                                                         
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1,3,                               
                                 CHANGE=(3,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'),           
                                 NOMATCH=(C'00'),                   
                                 13:13,2,FS,ZD,LENGTH=2)),         
      IFTHEN=(WHEN=(25,2,CH,EQ,C'PM',AND,13,2,CH,NE,C'12'),         
                        OVERLAY=(13:13,2,ZD,ADD,+12,LENGTH=3)),     
      IFTHEN=(WHEN=(25,2,CH,EQ,C'AM',AND,13,2,CH,EQ,C'12'),         
                        OVERLAY=(13:C'00')),                       
      IFTHEN=(WHEN=NONE,OVERLAY=(13:13,2))                         
OUTREC BUILD=(8,4,1,2,5,2,13,2,16,2,19,2,22,3)       
Back to top
View user's profile Send private message
mrdinesh

New User


Joined: 23 Sep 2006
Posts: 21
Location: India

PostPosted: Mon May 09, 2016 10:02 am    Post subject: Reply to: Convert Timestamp Value
Reply with quote

Hi Magesh,

Thanks for your Help. I was able to convert the timestamp with a different Sortcard, but similar to the one you posted.

Code:

 OPTION COPY                                                           
 INREC  IFTHEN=(WHEN=(05,1,CH,EQ,C' '),OVERLAY=(05:C'0'),HIT=NEXT),     
        IFTHEN=(WHEN=(13,1,CH,EQ,C' '),OVERLAY=(13:C'0'),HIT=NEXT),     
        IFTHEN=(WHEN=(25,2,CH,EQ,C'PM',AND,13,2,CH,NE,C'12'),           
                OVERLAY=(13:13,2,ZD,ADD,+12,TO=ZD,LENGTH=2),HIT=NEXT), 
        IFTHEN=(WHEN=(25,2,CH,EQ,C'AM',AND,13,2,CH,EQ,C'12'),           
                OVERLAY=(13:C'00'))                                     
 OUTREC BUILD=(8,4,1,3,CHANGE=(2,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'),NOMATCH=(C'  '),             
               5,2,13,2,16,2,19,2,22,3)                                 


Just have one small question - Is there any way to ignore the lower cases. In this I have to build the sort with only lower cases since the input file contains smaller cases. (This is not a real big issue, but anyhow the above sort solves the requirement).


Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon May 09, 2016 10:28 am    Post subject: Reply to: Convert Timestamp Value
Reply with quote

Why do you want the NOMATCH for the monts? What's your actual problem with the months and lower-case?

If you use CHANGE for the blank parts o the hours (first character of time) won't that do it? Then your IFTHEN is just for PM less than 12?

Why jam all your code together like that? You worked from magesh23586's example, which has better formatting than most, then decided to make it harder to read and change?

If you follow my suggestions, you'll greatly reduce the amount of code. Why not make what is left easier to read?
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 How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Convert +9999999999999.99 to S9(12)V9(3) vnktrrd DFSORT/ICETOOL 8 Thu Nov 17, 2016 8:15 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts convert PD to ZD ram_vizag DFSORT/ICETOOL 5 Sat Nov 05, 2016 3:06 am
No new posts help: convert C'00AB' to X'00AB' alan_gu DFSORT/ICETOOL 1 Thu Sep 29, 2016 12:22 pm


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