This is a discussion on how can I convert today's date into julian date within the COBOL forums, part of the Programming Talk category; format using IBM cobol..?...
|
|||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
There are intrinsic date functions that deal with the conversions of date formats like Julian Dates, Gregorian dates. I have mentioned some of them for your use below:
* Convert from Gregorian to Integer formats COMPUTE WS-INTEGER-DATE = FUNCTION INTEGER-OF-DATE (WS-DATE) * Convert from Integer to Gregorian formats COMPUTE WS-DATE = FUNCTION DATE-OF-INTEGER (WS-INTEGER-DATE) * Convert from Julian to Integer formats COMPUTE WS-INTEGER-DATE = FUNCTION INTEGER-OF-DAY (WS-JULIAN-DATE) * Convert from Integer to Julian formats COMPUTE WS-JULIAN-DATE = FUNCTION DAY-OF-INTEGER (WS-INTEGER-DATE) Let me know if you have any other query. |
|
|||
|
If you are like some who do not have the function options available, you could create a days in month table and calculate... you just have to deal with the Leap year. ie . if you divide the year by 4 and do not have a remainder and the date is after Feb, add 1 to the julian day. ... of course there is the 400 year to consider if not this year.
working-storage 01 ws-days-in-month-table. 05 ws-days-in-month pic x(24) value "312831303130313130313031". 05 ws-days-in-mo redefines ws-days-in-month pic 9(02). ... 05 ws-julian-date. 10 ws-julian-yr pic 9(02) value zero. 10 ws-julian-day pic 9(03) value zero. 05 ws-date. 10 ws-year pic 9(02) value zero. 10 ws-month pic 9(02) value zero. 10 ws-day pic 9(02) value zero. 05 i pic 9(02) value 01. Procedure accept ws-date from date. move ws-year to ws-julian-yr. compute i = ws-month - 1. if i = zero move 12 to i. compute ws-julian-day = ws-days-in-mo(i) + ws-day. Last edited by eddie13 : 07-26-2007 at 02:38 PM. |
![]() |
| Thread Tools | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date Validation using SimpleDateFormat() | insane | Java Tutorials | 0 | 05-05-2006 12:20 PM |
| comp.lang.c Answers to Frequently Asked Questions (FAQ List) | Steve Summit | Tech FAQ | 0 | 06-01-2004 06:00 AM |
| Robot Competition FAQ for June 2004 | R. Steven Rainwater | Tech FAQ | 0 | 05-27-2004 08:59 PM |
| [FAQ] FileMaker Pro - database for Macintosh and Windows | Martin Trautmann | Tech FAQ | 0 | 04-17-2004 07:26 AM |
| comp.os.msdos.programmer FAQ part 1/5 | Jeffrey Carlyle | Tech FAQ | 1 | 04-09-2004 07:57 AM |