Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual FoxPro
Expertise: Beginner
Feb 8, 2000



Application Security Testing: An Integral Part of DevOps

Converting Julian Dates to Gregorian Dates

How do I change a Julian date to a Gregorian date and remain Y2K compliant?

I am not sure how the year is stored in the Julian date, so I will suppose that it is at the beginning of the Julian string for the sake of this solution. I will also assume that the Julian date is stored as a character value.

Let's assume there is a Julian date 1999003, which would be Jan 3, 1999. Create a PRG file with the following code in it:


PROCEDURE ConvertJulianToDate

LOCAL lcJulianYear,lcJulianNumber
LOCAL lnJulianNumber, ldReturnValue

lcJulianYear = LEFTC(tcJulianDate,4)
lcJulianDay  = RIGHTC(tcJulianDate,3)
lnJulianDay  = VAL(lcJulianDay)

*-- Create a date that is Jan 1st of Julian year
ldReturnValue = CTOD("01/01/"+lcJulianYear)

*-- Add the numeric Julian date and subtract
*-- one because Jan 1 = 1, not zero
ldReturnValue = ldReturnValue + lnJulianDay - 1

RETURN ldReturnValue
DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date