MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Julian to Gregorian Date Conversion

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Thu Jan 08, 2004 5:44 am    Post subject: Julian to Gregorian Date Conversion Reply with quote

Hi All,

I have a 80 column file as follows

The data is "space" separated.

JOBNAME ; JOB_NUM; QUE_DATE;QUE_TIME; ST_DATE;ST_TIME; ERROR
PRODJOB1 06832 2004002 101700 2004002 101900 RC=0000
PRODJOB2 11194 2004003 022300 2004003 022800 U2222

The julian date values starts at column 22 & 41 .I want to convert the Julian date to Gregorian date (YYYYMMDD) by some utility. I need this conversion for around 10000 rows everyday.

Also please suggest way to find the difference in times (Que_time & St_time) for the in In_Queue time of the jobs.

The output should be like this (In_Queue_time hhmmss)

JOBNAME ; JOB_NUM; QUE_DATE;QUE_TIME; ST_DATE;ST_TIME; ERROR IN_QUE_TIME
PRODJOB1 06832 2004002 101700 2004002 101900 RC=0000 000200
PRODJOB2 11194 2004003 022300 2004003 022800 U2222 000500

Thanks
Shiv
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 08, 2004 10:59 am    Post subject: Reply with quote

Shiva,

The following DFSORT JCl will give you the desired results. I asumming that you have the latest versions of either DFSORT or syncsort. A brief explanation of the job. We are using date parm DT1 to convert the date. the source to DTn formats is a 4-byte packed decimal format(P'cyyddd'). The c in the date source P'cyyddd' represents the century. It is converted as follows: 0 is converted to 19, 1 is converted to 20, and 2 or greater is converted to 21. so using a change command we change the century portion. And using outrec fields we change the zoned decimal date to packed decimal and using OUTREC we edit mask the date field to the desired format. I am assuming that your input file is of 80 bytes in length is of FB format.

Code:

//STEP0100 EXEC PGM=SORT                                         
//SYSOUT   DD SYSOUT=*                                           
//SORTIN   DD *                                                   
PRODJOB1 06832       2004002 101700     2004002 101900 RC=0000   
PRODJOB2 11194       2004003 022300     2004003 022800 U2222     
//SORTOUT DD SYSOUT=*                                             
//SYSIN   DD *                                                   
  SORT FIELDS=COPY                                                 
  INREC FIELDS=(01,21,                                             
                22,2,CHANGE=(1,C'19',C'0',                         
                               C'20',C'1',                         
                               C'21',C'2'),NOMATCH=(C'2'),         
                24,5,                                             
                29,12,                                             
                41,2,CHANGE=(1,C'19',C'0',                         
                               C'20',C'1',                         
                               C'21',C'2'),NOMATCH=(C'2'),         
                43,5,                                             
                48,33)                                             
  OUTREC FIELDS=(01,21,                                           
                22,6,ZD,PD,LENGTH=4,28,12,                       
                40,6,ZD,PD,LENGTH=4,46,33)                       
  OUTFIL OUTREC=(1,21,22,4,DT1,EDIT=(TTTTTTTT),X,26,13,           
                 38,4,DT1,EDIT=(TTTTTTTT),42,29)                 
/*


The output of this job is :

Code:

PRODJOB1 06832       20040102  101700      20040102 101900 RC=0000         
PRODJOB2 11194       20040103  022300      20040103 022800 U2222           


Hope this helps...

cheers

kolusu

PS: I will post the job to do the time difference also later.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 08, 2004 12:26 pm    Post subject: Reply with quote

shiv,

The calculation between two times gets tricky when you involve the seconds portion also into it. you need to convert everything to secs and then get the difference between them in seconds. Then once again you need to convert the difference back to hours and mins.

The calculation in seconds can be done in sort but it would be too complicated.It gets complicated when the start time of the JOb is on the end of the year. Let us take this example

JOB a starts on 10:00:32 PM on DEC 31st 2003 and ends on 02.30:22 AM on Jan 1st 2004. Now your jobstats for this job would be as follows:

Code:


JOBNAME ; JOB_NUM; QUE_DATE;QUE_TIME; ST_DATE; ST_TIME; ERROR
PRODJOB1  06832    2003365   100032   2004001  023022   RC=0000

Now the time difference is 4 hours 29 mins 50 secs.

In order to get the you need to consider the year , date, hour, min and seconds.

Ideally I would code a cobol program to calculate the time difference using language environment callable services like CSEESECS.

If you don't care about the seconds , then the following JCL will give you the time difference in mins.This job will also perform the date conversion in addition to calculating the time difference.

Code:

//STEP0300 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                     
PRODJOB1 06832       2004002 101700     2004002 101900 RC=0000     
PRODJOB2 11194       2004003 022300     2004003 022800 U2222       
//SORTOUT DD SYSOUT=*                                               
//SYSIN   DD *                                                     
  SORT FIELDS=COPY                                                   
  INREC FIELDS=(01,21,                                               
                22,2,CHANGE=(1,C'19',C'0',                           
                               C'20',C'1',                           
                               C'21',C'2'),NOMATCH=(C'2'),           
                24,5,                                               
                29,12,                                               
                41,2,CHANGE=(1,C'19',C'0',                           
                               C'20',C'1',                           
                               C'21',C'2'),NOMATCH=(C'2'),           
                43,5,                                               
                48,18,                                               
                (+1440,MUL,(22,4,ZD,SUB,41,4,ZD)),EDIT=(TTTTTTTT),   
                X,(32,2,ZD,ADD,(+60,MUL,30,2,ZD)),EDIT=(TTTTTTTT),   
                X,(51,2,ZD,ADD,(+60,MUL,49,2,ZD)),EDIT=(TTTTTTTT))   
  OUTREC FIELDS=(01,21,                                             
                22,6,ZD,PD,LENGTH=4,28,12,                           
                40,6,ZD,PD,LENGTH=4,46,18,                           
                ((64,8,ZD,ADD,73,8,ZD),SUB,82,8,ZD),EDIT=(TTTTTTTT))
  OUTFIL OUTREC=(1,21,22,4,DT1,EDIT=(TTTTTTTT),X,26,13,             
                 38,4,DT1,EDIT=(TTTTTTTT),42,26,80:X)               
/*                                                                 


The output from this job is as follows:
Code:

PRODJOB1 06832       20040102  101700      20040102 101900 RC=0000   00000002
PRODJOB2 11194       20040103  022300      20040103 022800 U2222     00000005


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
shiv_swami
Beginner


Joined: 29 Nov 2003
Posts: 68
Topics: 14

PostPosted: Thu Jan 15, 2004 5:32 am    Post subject: Reply with quote

Kolusu,

Thanks a lot.You are great !!!
I could not connect to mainframe for more than a week after I up the post.Sorry for the late response to your solution.
I have SYNCSORT at my shop & tried running the above solution,
It works wondefull well.

Regards,
Shiv
_________________
Why Walk when you can Run Arrow ?
Nicola Iacocca
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu Jan 15, 2004 12:13 pm    Post subject: Reply with quote

Shiv,

Thanks for the feedback. well I am just an application programmer. Nothing great about it. I am happy that my proposed solution worked out for you.

Thanks

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Nov 16, 2009 6:05 pm    Post subject: Reply with quote

shiv_swami,

With z/OS DFSORT V1R5 PTF UK51706 or z/OS DFSORT V1R10 PTF UK51707, you can use the new date conversion function TOGREG like shown below to get the desired results
Code:

//STEP0100 EXEC PGM=SORT                                       
//SYSOUT   DD SYSOUT=*                                         
//SORTIN   DD *                                               
PRODJOB1 06832       2004002 101700     2004002 101900 RC=0000
PRODJOB2 11194       2004003 022300     2004003 022800 U2222   
//SORTOUT  DD SYSOUT=*                                         
//SYSIN    DD *                                               
 SORT FIELDS=COPY                                             
 INREC BUILD=(1,21,22,7,Y4T,TOGREG=Y4T,29,12,                 
              41,7,Y4T,TOGREG=Y4T,48,31)                       
//*


For complete details on date conversion functions and the other new functions available with the Nov, 2009 DFSORT PTF, see:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000174
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group