Reply To: Julian to calendar date conversion

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Julian to calendar date conversion Reply To: Julian to calendar date conversion

#58084
Walter Ericson
Participant

    Rob,

    I use a function in Unix AIX 5.2 (korn shell) to get the last day of the month:

    last_day_of_month()

    {

    /usr/bin/cal $1 $2 | /usr/bin/awk ‘{if ($NF) Last=$NF}

    END{printf(“%sn”,Last);}’;

    }

    Sample useage (in korn shell script):

    YESTERDAY=`last_day_of_month $LASTMONTH $YEAR`;

    You may have to find cal and awk on your system!!

    cal is a calender call, the $1 is month value and $2 is a year.  

    The awk command gets the last field with a value from the calender display.

    You will also have to put in conditions for first of the year.

    In tcl you can use something like

    hcitcl>clock format [clock scan “today -1 day”] -format %Y%m%d

    20051228

    The clock scan command will parse many words.

    I have not had any luck converting julian to YYYYMMDD.

    Walter Ericson