View previous topic :: View next topic
|
Author |
Message |
PORYES
New User
Joined: 04 Apr 2007 Posts: 38 Location: Chennai
|
|
|
|
Hi -
How to remove the Hyphens and Dots from the below date time format.
2020-04-28-07.40.30
I am using DATE4 function to get the date time format, But My output should not contain any '-' and '.'
Output shout be: 20200428074030
Can someone help me?
My Syncsort version is : 2.1 |
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1341 Location: Bamberg, Germany
|
|
|
|
Input:
Code: |
//DATE4 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTREC OVERLAY=(1:DATE4,
21:1,19,UFF,LENGTH=15)
/* |
Output:
Code: |
2020-04-28-20.56.49 20200428205649 |
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
2020-04-28-20.56.49
/*
//SORTLIST DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//ANY DD DUMMY
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'-,.')) |
Output-
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1341 Location: Bamberg, Germany
|
|
|
|
Code: |
//SORTIN DD *
2020-04-28-20.56.49
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,4,6,2,9,2,12,2,15,2,18,2)
/* |
|
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
haha - Many more ways
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
2020-04-28-20.56.49
/*
//SORTLIST DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//ANY DD DUMMY
//SYSIN DD *
SORT FIELDS=COPY
INREC FINDREP=(INOUT=(C'-',C'',
C'.',C'')) |
Output-
|
|
Back to top |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1341 Location: Bamberg, Germany
|
|
|
|
Code: |
//ANOTHER EXEC PGM=SORT
//SORTIN DD *
2020-04-28-20.56.49
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=INIT,
PARSE=(%1=(STARTAT=NUM,FIXLEN=4),
%2=(STARTAT=NUM,FIXLEN=2,REPEAT=5)),
OVERLAY=(21:%1,%2,%3,%4,%5,%6))
/* |
Output:
Code: |
2020-04-28-20.56.49 20200428205649 |
That's now a couple of options to chose from, I'd say. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3076 Location: NYC,USA
|
|
|
|
Yes and if TS wants more we have more ways 👍 |
|
Back to top |
|
|
PORYES
New User
Joined: 04 Apr 2007 Posts: 38 Location: Chennai
|
|
|
|
Thanks everyone for your help! |
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2147 Location: USA
|
|
|
|
This suggestion by Joerg is the most suitable to the author's situation, I guess
I would update it to the following
Code: |
UFF,EDIT=(TTTTTTTTTTTTTTT) |
as a "fool-proof" solution (to fill with zeroes in case some wrong data detected on input instead of a correct timestamp) |
|
Back to top |
|
|
|