Exforsys
+ Reply to Thread
Results 1 to 4 of 4

how can I convert today's date into julian date

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..?...

  1. #1
    mapzaplap is offline Junior Member Array
    Join Date
    Mar 2007
    Answers
    1

    how can I convert today's date into julian date

    format using IBM cobol..?


  2. #2
    rachelle is offline Member Array
    Join Date
    Apr 2006
    Answers
    97
    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.


  3. #3
    eddie13 is offline Junior Member Array
    Join Date
    Jul 2007
    Answers
    8
    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.

  4. #4
    eddie13 is offline Junior Member Array
    Join Date
    Jul 2007
    Answers
    8
    of course some compilers (Liants RMCOBOL is one) have the "accept ws-julian-day from day" function for today's date. the other works when you need a date that is not today.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...