Home      Mainframe Forum      Mainfarme Tutorials      IBM Manuals      Mainframe Interview Questions      Mainframe Books      IT News     SiteMap     Downloads


     
 
MAINFRAME - TIP OF THE DAY : When you specified V for RECFM parameter, LRECL value is largest record in the file plus 4 bytes. These four bytes contain the actual length of each variable length record in the file

Google
 
Web mainframegurukul.com

How to convert Julian date format into yyyymmdd date format?

 
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL
  View previous topic :: View next topic  
Author Message
thamodharan
Member


Joined: 21 Oct 2008
Posts: 21
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Tue Mar 31, 2009 4:08 pm    Post subject: How to convert Julian date format into yyyymmdd date format? Reply with quote

Hi friends,

I need to convert the julian date format to yyyy/mm/dd format.
Is there any facility to do this? or Should we write any routine for this?
please let me know if there is any easy way to convert this...

Thanks...
[/b]
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.

Natarajan
Moderator


Joined: 10 Oct 2008
Posts: 537
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
1 salutes

PostPosted: Tue Mar 31, 2009 4:20 pm    Post subject: julian date to YYYYMMDD Reply with quote

Hi Thamodharan,

Welcome to mainframegurukul.com

You can convert julian date format ( YYDDD) TO YYYYMMDD format using following intrinsic functions.


Code:

 ws-date-int = FUNCTION INTEGER-OF-DAY(argument-1)


The INTEGER-OF-DAY function converts a date in the Gregorian calendar from Julian date form (YYYYDDD) to integer date form.

Then use following function, with this value you got from above function.

Code:

 date-YYYY-MM-DD  =   FUNCTION DATE-OF-INTEGER(ws-date-int)


The DATE-OF-INTEGER function converts a date in the Gregorian calendar from integer date form to standard date form (YYYYMMDD).


After that you can use your own logic to add slashes between year, date, day parts.


Let me now, if you have any other questions.
_________________
Natarajan
Chennai
Back to top
View user's profile Send private message Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
thamodharan
Member


Joined: 21 Oct 2008
Posts: 21
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Apr 01, 2009 12:35 pm    Post subject: Reply with quote

Thank you Natarajan for your reply.

Will it be allowable by all the compilers?

My compiler is not accepting the FUNCTION keyword.
what shall i do for that? should i change any compiler options to make FUNCTION acceptable?

Thank you once again.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Natarajan
Moderator


Joined: 10 Oct 2008
Posts: 537
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Apr 01, 2009 3:16 pm    Post subject: Reply with quote

Try using RENT compiler option.

Let me know, if it is not working.
_________________
Natarajan
Chennai
Back to top
View user's profile Send private message Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
dbzTHEdinosauer
Moderator


Joined: 02 Oct 2006
Posts: 981

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Apr 01, 2009 4:17 pm    Post subject: Reply with quote

Try writing the code omitting the 'FUNCTION' keyword.
_________________
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Natarajan
Moderator


Joined: 10 Oct 2008
Posts: 537
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Apr 02, 2009 9:41 am    Post subject: Julian date ( YYDDD) format into yyyymmdd date format Reply with quote

Here is the process to convert Julian date (YYDDD) format into yyyymmdd date format,if you want to code the logic without using functions.


Steps to folllow.

Step 1 - take the year part and find out whether it is leap year or not
Code:

 IF A YEAR DIVISIBLE BY 400
 THEN IT IS A LEAP YEAR.   
 IF A YEAR DIVISIBLE BY 4   
 BUT NOT DIVISIBLE BY 100 
 THEN IT IS A LEAP YEAR.   
 


Step 2 - If it is leap year.. increase the no. of days in Feb by 1

Step 3 - Now we need to find out.. which month we are in.
Take DDD part... which contains the no of day from starting of the year.

check as below to get MM value..
if the value in DDD less than or equal 31.. then month is Jan0
if the value in DDD less than or equal ( 31+ 28 (29, if leap year) )
then the month is Feb
etc....

You better code these numbers in an array, so that while coding
you can use perform to get MM value... without writing too much of code.

Code:

  example -
   01  months
        05  jan     pic 9(3)  value 0
        05  feb     pic 9(3)  value 31
        05  mar    pic 9(3)  value 59
    etc....
   redefine above structure with an array , so that accessing this data will be easy.



Step 4 - Need to find out day part ...


Example - if the given day fall under in the month of April.
If MM has the value of 4 which means april...
your code should work in such way .. it should subtract 90 ( you can take from above array) from DDD
resultant value will be moved to DD part

In case of Feb, need to subtract 31 from DDD and resultant value will be
moved to DD part. etc...

This logic also can be coded using above array.



calculating century part fully depends upon.. where you will use this code...normally people use window... i.e.,

If YY > 50
MOVE 1900 TO CC-YY
else
MOVE 2000 TO CC-YY
end-if

Let me know, if you need any more help on this.
_________________
Natarajan
Chennai
Back to top
View user's profile Send private message Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
thamodharan
Member


Joined: 21 Oct 2008
Posts: 21
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Apr 08, 2009 1:24 pm    Post subject: Reply with quote

Hi,

Yes its fixed now...
thanks for your quick reply.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Natarajan
Moderator


Joined: 10 Oct 2008
Posts: 537
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Apr 08, 2009 3:20 pm    Post subject: Reply with quote

Let us know, which method you have used.
_________________
Natarajan
Chennai
Back to top
View user's profile Send private message Visit poster's website
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
thamodharan
Member


Joined: 21 Oct 2008
Posts: 21
Location: chennai

Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Thu Apr 09, 2009 12:41 pm    Post subject: Reply with quote

Hi,

First I tried with RENT compiler option. But it was not working that time.
Then I have written a seperate routine as you said. Now its fine...

Thanks,
Thamu.
Back to top
View user's profile Send private message
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Wed Jan 27, 2016 8:22 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jan 30, 2016 11:42 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Sat Jan 30, 2016 11:43 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
academyindia4
Guest





Answer was approved by Question owner.
Useful Post
0 votes
Not an useful post
Greate Post!! Salute Author
0 salutes

PostPosted: Mon Feb 01, 2016 10:09 pm    Post subject: Topic deleted by Admin Reply with quote

<< Content deleted By Admin >>
Back to top
Click here, If this post answer your question. <-- Click on right mark icon. If this post answer your question.
Display posts from previous:   
Post new topic   Reply to topic    mainframegurukul.com Forum Index -> COBOL 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


Cobol Tutorial
This cobol tutorial covers most of the important topics like STRING, UNSTRING, COMP, COMP-3.....
DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. Explains in simple language. Some Chapters are locked, Forum members have free access to these chapters
CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming...
JCL Tutorial
This is most popular JCL tutorial from mainframegurukul. It does contain important jcl ....
SORT Tutorial
This Tutorial covers all important aspects of DFSORT. Has more SORT examples
INTERVIEW Questions
This page covers important interview questions
Mainframe Jobs
Mainframe Jobs posted by members of mainframegurukul forum
FaceBook Page
MainframeGurukul FaceBook Page
LinkedIn Page
MainframeGurkul Linkedin Page

This widget requires Flash Player 9 or better







Go to top of the page
 

Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  DB2 INTERVIEW QUESTIONS ||  COBOL INTERVIEW QUESTIONS  ||  JCL INTERVIEW QUESTIONS ||  JCL2 INTERVIEW QUESTIONS ||  VSAM INTERVIEW QUESTIONS ||  CICS INTERVIEW QUESTIONS  ||  Online tutorials ||  Online ABEND Reference ||  JCL References ||  COBOL References ||  VSAM References ||  Tutorials by Drona Series ||  SQL tutorial ||  BOOKS  ||  SiteMap  ||  Expeditor Tutorial  ||  FILE-AID Tutorial  ||  Changeman Tutorial  ||  COBOL   ||  DB2   ||  JCL  ||  CICS  ||  VSAM  ||  DB2 Interview Questions ( 110 )   || Simple JCL Tutorials  || JCL Tutorial from MainframeGurukul.com   || Simple JCL Tutorial - Chapter1 ;|| Mainframe Forum - Tutorials  || Mainframe Tutorials || Mainframe CICS tutorial|| Mainframe COBOL Tutorial

Drona Educational Forums - Mainframe Cobol DB2 CICS Board
Powered by phpBB

mainframetopic-3974.html