dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
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

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Converting Julian Dates to Gregorian Dates

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

Answer:
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:

?ConvertJulianToDate("1999003") 

PROCEDURE ConvertJulianToDate
LPARAMETERS tcJulianDate

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
ENDPROC
DevX Pro
 
Comment and Contribute

 

 

 

 

 


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

 

 

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