IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert Julian to Gregorian


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Fri Jul 20, 2018 7:00 pm
Reply with quote

Hi,

I have symbol (SYSNAMES) built using below code:

Code:
OPTION COPY                               
INREC BUILD=(C'MYDATE,''',15,5,C'''',80:X)


This result in

Code:
MYDATE,'18170'


Julian date in YYDDD format. In next step, I want to covert this into Gregorian format (CCYYMMDD) and OVERLAY at position 15.

I have below code in step 2.
Code:
OPTION COPY                                         
OUTREC IFTHEN=(WHEN=INIT,                           
             OVERLAY=(15:MYDATE,15,5,Y2T,TOGREG=Y4T))


This resulting in:
Code:
C00000010I1817020180619


My expected result is:
Code:
C00000010I20180619


I searched forum, there are various examples on this conversion but none of them uses symbol.

Many thanks.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 20, 2018 7:29 pm
Reply with quote

zh_lad,

You could try creating the symbol itself in Gregorian format in your step1 and use it in Step2.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Jul 20, 2018 7:38 pm
Reply with quote

What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???

Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it.
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Fri Jul 20, 2018 7:47 pm
Reply with quote

Thanks Arun. My input date file has date in three formats:
YYMMDD, DDMMYY, YYDDD

Yes I can use YYMMDD format for this particular step (input file).

However, I have to write lots of steps to change the date on different input files, all have different date format. This would mean, for each input file, I will have to create symbol file.

I was hoping TOJUL and TOGREG will allow to get all the formats I need.
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Fri Jul 20, 2018 7:52 pm
Reply with quote

sergeyken wrote:
What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???

Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it.


I want to re use SYSNAMES dataset to populate date on different files.
I want to user to provide date
Yes, I know but I didn't know how to convert date same time at position 15.

Thanks.

Please note file is VB.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Jul 20, 2018 8:05 pm
Reply with quote

zh_lad wrote:
sergeyken wrote:
What is the idea of full mess-up when dealing with SYMNAMES in your task???
What is the role, or any benefit from your MYDATE???

Now you get what you have requested: at position 15 there is your original date, while converted date goes right next to it.


I want to re use SYSNAMES dataset to populate date on different files.
I want to user to provide date
Yes, I know but I didn't know how to convert date same time at position 15.

Thanks.

Please note file is VB.

Split the two of them (value substitution, and date conversion)

1) either into INREC + OUTREC,
2) or into separate WHEN=...,OVERLAY= groups
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 20, 2018 8:10 pm
Reply with quote

zh_lad wrote:
Thanks Arun. My input date file has date in three formats:
YYMMDD, DDMMYY, YYDDD

Yes I can use YYMMDD format for this particular step (input file).

However, I have to write lots of steps to change the date on different input files, all have different date format. This would mean, for each input file, I will have to create symbol file.

I was hoping TOJUL and TOGREG will allow to get all the formats I need.
How about creating 3 different date symbols corresponding to each date format, write all of them in your SYMNAMES once and then use whichever you want in the subsequent steps.

Something like this:
Code:
//STEP01  EXEC PGM=SORT                                   
//SYSOUT    DD SYSOUT=*                                   
//SORTIN    DD *                                           
18170                                                     
//SORTOUT   DD SYSOUT=*                                   
//SYSIN     DD *                                           
  OPTION COPY                                             
  OUTFIL BUILD=(C'MYDATEJ1,''',01,5,C'''',80:X,/,         
                C'MYDATEG1,''',01,5,Y2T,TOGREG=Y4T,C'''',/,
                C'MYDATEG2,''',01,5,Y2T,TOGREG=Y4W,C'''') 
would give:
Code:
MYDATEJ1,'18170'   
MYDATEG1,'20180619'
MYDATEG2,'06192018'
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Fri Jul 20, 2018 8:17 pm
Reply with quote

Thanks sergeyken.

I did try INREC + OUTREC but I couldn't syntax right. I will try little better this time.

Thanks. I didn't realise I have multiple IFTHEN and WHEN. Will try both options.

Cheers
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Mon Jul 23, 2018 3:48 pm
Reply with quote

Thanks Arun. I have gone with having multiple symbols method. It's quite easy to use. I wasn't aware we can use more than one symbol on a file.

Here is my input date file:

Code:
180619 190618 18170 200618 18171 18169     000000Y                         TUE13


Here is my sort code to create symbols, dates in different format:
Code:

OPTION COPY                                           
OUTFIL BUILD=(C'MYDATE,''',1,6,C'''',80:X,/,         
      C'MYDATEJ1,''',15,5,C'''',/,                   
      C'MYDATEG1,''',15,5,Y2T,TOGREG=Y4T,C'''',/,     
      C'MYDATEG2,''',15,5,Y2T,TOGREG=Y2T(/),C'''',/, 
      C'MYDATEG3,''',15,5,Y2T,TOGREG=Y4W,C'''',/,     
      C'MYDATEG4,''',8,6,C'''',/,                     
      C'MYDATEG5,''',8,2,C'/',10,2,C'/',12,2,C'''',/,
      C'MYDB2DT1,''',15,5,Y2T,TOGREG=Y4T(-),C'''')   


Here is what it produces:
Code:
MYDATE,'180619'     
MYDATEJ1,'18170'     
MYDATEG1,'20180619' 
MYDATEG2,'18/06/19' 
MYDATEG3,'06192018' 
MYDATEG4,'190618'   
MYDATEG5,'19/06/18' 
MYDB2DT1,'2018-06-19'


I am now cruising along in amending dates on 200 odd files. This jcl will be used often to move dates to a new date for 200 files.

Thanks and regards.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Mon Jul 23, 2018 6:24 pm
Reply with quote

zh_lad,

Thanks for posting. Glad it worked out well for you.!
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Tue Jul 24, 2018 4:19 pm
Reply with quote

Hi again,

Is there any function or keyword which can convert Julian date to DDMMCCYY.

I can see Arun has used:

Code:
C'MYDATEG3,''',15,5,Y2T,TOGREG=Y4W,C''''


to convert Julian date into MMDDCCYY.

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

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Jul 24, 2018 4:44 pm
Reply with quote

Not from what I can see in the manual. Seems strange that one of the most used formats is not catered for.
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Tue Jul 24, 2018 5:48 pm
Reply with quote

yeah.

I have built is from DDMMYY (P8,L6).

Code:
C'MYDATEG6,''',8,4,C'20',12,2,C'''',/,



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

Active Member


Joined: 30 Nov 2013
Posts: 917
Location: The Universe

PostPosted: Tue Jul 24, 2018 6:52 pm
Reply with quote

  • What bone head designed the contents of this data set? Well, that's something we will never know. Not 20 years ago our industry went through considerable pain to resolve issues with two digit dates and we still have boneheads putting 2 digit years into data. Resolving the same issues in the 2090s will be even more of a nightmare than the Y2K issues in the 1990s. At least 2000 was a leap year. 2100 is not.
  • The sort products have built in tools to transform two digit years to correct 4 digit years. These tools will not work correctly in 20 or 30 years, but they work correctly now. Find these tools in your sort product documentation and use them.
  • Dates expressed as yyddd have often been called a "Julian" date. This is not correct. A Julian date is a date expressed, for the most part, like any other date.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Jul 24, 2018 9:52 pm
Reply with quote

zh_lad wrote:
yeah.

I have built is from DDMMYY (P8,L6).

Code:
C'MYDATEG6,''',8,4,C'20',12,2,C'''',/,



Thanks.
You could do the conversion just once from YYDDD to CCYYMMDD and then in the output, just rearrange the data as you need instead of trying to convert for each symbol.
Back to top
View user's profile Send private message
zh_lad

Active User


Joined: 06 Jun 2009
Posts: 115
Location: UK

PostPosted: Fri Jul 27, 2018 9:33 pm
Reply with quote

Thanks Arun.

One last question on this thread.
Is there a way I can draw or convert date into DD-MMM-YY (e.g. 19-JUN-18) or similar format where first three letters of month is displayed?

I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).

Cheers
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Fri Jul 27, 2018 10:30 pm
Reply with quote

zh_lad wrote:
Thanks Arun.

One last question on this thread.
Is there a way I can draw or convert date into DD-MMM-YY (e.g. 19-JUN-18) or similar format where first three letters of month is displayed?

I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).

Cheers

1) first, convert to
Code:
 ...DD/MM/YY...

2) then use
Code:
 FINDREP=(INOUT=(C'/01/',C'-JAN-',
             . . . . . . . . . . . . .
             C'/12/',C'-DEC-'))
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sat Jul 28, 2018 3:49 am
Reply with quote

Quote:
I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).
You could OVERLAY a 3 character month at the end of your input record and use it in your OUTFIL.
Code:
//STEP01   EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTOUT  DD SYSOUT=*                                         
//SORTIN   DD *                                               
180619 190618 18170 200618 18171 18169     000000Y             
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:03,2,X)),               
        IFTHEN=(WHEN=INIT,                                     
       FINDREP=(INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',
                       C'04',C'APR',C'05',C'MAY',C'06',C'JUN',
                       C'07',C'JUL',C'08',C'AUG',C'09',C'SEP',
                       C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'),
       STARTPOS=81))
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Sat Jul 28, 2018 5:56 am
Reply with quote

Arun Raj wrote:
Quote:
I understand I can have conditional check on MM (06) to populate first three bytes of month name (in this case JUN).
You could OVERLAY a 3 character month at the end of your input record and use it in your OUTFIL.
Code:
//STEP01   EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTOUT  DD SYSOUT=*                                         
//SORTIN   DD *                                               
180619 190618 18170 200618 18171 18169     000000Y             
//SYSIN    DD *                                               
  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:03,2,X)),               
        IFTHEN=(WHEN=INIT,                                     
       FINDREP=(INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',
                       C'04',C'APR',C'05',C'MAY',C'06',C'JUN',
                       C'07',C'JUL',C'08',C'AUG',C'09',C'SEP',
                       C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'),
       STARTPOS=81))

FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names!
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sat Jul 28, 2018 8:01 am
Reply with quote

sergeyken wrote:
FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names!
Enclosing in separators is not really required. If you notice the control statements above, only the month portion is OVERLAYed at pos-81 and the FINDREP scanning is set to start at pos-81 to convert the month(mm) to JAN, FEB, etc... The rest of the data would remain unaffected.
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Sun Jul 29, 2018 9:42 am
Reply with quote

Arun Raj wrote:
sergeyken wrote:
FINDREP= must convert digits enclosed in separators. Otherwise also days, and/or years, and/or combinations of days/months/years could be converted to month names!
Enclosing in separators is not really required. If you notice the control statements above, only the month portion is OVERLAYed at pos-81 and the FINDREP scanning is set to start at pos-81 to convert the month(mm) to JAN, FEB, etc... The rest of the data would remain unaffected.

Not recommended, and non-flexible approach. Such methods, in general, are the main reasons why modern software requires monthly/weekly/daily/hourly updates, while old stable programs do work for years and years without problems.
Back to top
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sun Jul 29, 2018 4:36 pm
Reply with quote

The STARTPOS ENDPOS subparameters are there just to serve this very purpose. Ie. To limit the FIND REPLACE to specific positions. I don't see how it will be a non flexible approach. And old stable programs working for several years without any problems has nothing to do with this.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
No new posts Convert HEX to Numeric DB2 3
Search our Forums:

Back to Top