Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Julian Dates for input, to a Fox2.5 Program

Status
Not open for further replies.

HankK

MIS
Nov 9, 2000
3
US
I have a program in FPD 2.5. I use a client upload program to import work to the databases. I have a client that used to give me dates as "19991231" yyyymmdd. I converted with the function: CTOD(SUBSTR(DT,5,2)+'/'+SUBSTR(DT,7,2)+'/'+SUBSTR(DT,1,4)). They just recently changed to the
Julian format 'yyyyddd'=2000314. I know the 314 day of year 2000 is today. But I can't figure out a conversion function.
Could some one please help. Thanks a mil.

Hank
 
Hank,
These routines have served me well. Note that they do assume that the current date format is AMERICAN or MDY.

Rick

*** --------------------------------------------------- ***
***
*** These routines convert JULIAN (Day of Year) to Dates.
***
*** date2jul(date) : Date to Julian (DOY) number
***
*** jul2date(int, int) : Year and DOY to Date
***
*** EXAMPLES:
***
*** ? date2jul({1/1/95})
*** ? date2jul(jul2date(1995, 30))
*** ? jul2date(1994, date2jul({12/31/94}))
***
*** --------------------------------------------------- ***

*!*********************************************************
*! Function: DATE2JUL()
*!*********************************************************
FUNCTION date2jul
PARAMETERS zdate
PRIVATE zdate
*
* input zdate (date)
* output date2jul (number)
*
IF !EMPTY(zdate)
RETURN INT(VAL(SYS(11,zdate)) - ;
VAL(SYS(11,'01/01/'+ALLTRIM(STR(YEAR(zdate)))))+1)
ELSE
RETURN 0
ENDIF

*!*********************************************************
*! Function: JUL2DATE()
*!*********************************************************
FUNCTION jul2date
PARAMETERS zyear, zjul
PRIVATE zyear, zjul
*
* input zyear (number)
* zjul (number)
* output jul2date (date)
*
&& zjul is base 1 - have to adjust
RETURN CTOD('01/01/'+STR(zyear))+zjul-1

*** --------------------------------------------------- ***
 
Thanks, RGBean for providing an answer to HankK's question.

And now for something completely different:

Julian date is NOT the day of the year. A Julian date is the number of days since January 1, 4713 B.C. Today's Julian Date is 2451859.

Robert Bradley

 
Robert,
Exactly right, that's why I was careful to include the notation about the Day Of Year (DOY). It's just that some managers require you to use their terminology, whether it's right or wrong. (As a state government employee, I had a dispute with the personel department that insisted that Noon was 12:00 AM, because that's what the employee handbook said it was <s>. For a discussion on this go to - you can't get more definitive than this!)

Rick
 
Ahh, that brings back memories. In June I left a contract where I had worked at a state government agency that shall remain nameless (but its the second largest in land area). I never really understood this whole trend towards outsourcing until then; now I completely understand why agencies such as state government often bring in contractors.

Ooops! Sorry for getting off-track.

Robert Bradley

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top