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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Julian Date To Calendar Date

Status
Not open for further replies.

yeewaitu

Technical User
Nov 13, 2003
39
SG
Does anyone know how to use impromptu to convert julian date (eg: 103118) to calendar date (28/04/03) using the basic date functions in impromptu?

Please help. Thanks!

 
This will convert the example you gave but it seems a very strange start date

add-days (1720-12-29 , 103118)

or

datetime-to-date(days-from-1900-to-datetime(103118,65380))

HTH

Gary

Gary Parker
MIS Data Analyst
Manchester, England
 
Can I ask why is the start date very strange?

Can this formula handle leap years?
 
In my experience most db's tend to set there dates form the start of a year that's all.

You'll need to test the formulas to check leap years.



Gary Parker
MIS Data Analyst
Manchester, England
 
Sorry to butt in, but I think yeewaitu's example is incorrect; calendar date 28/04/(20)03 is 2452758 in Julian days. I suspect this is what Gary means when he mentions 'strange'.

On this basis, Gary's solution would be
Code:
datetime-to-date(days-from-1900-to-datetime(2452758-2415020))
2415020 is 31st December 1899 in Julian


soi la, soi carré
 
This might be a more precise method, although lacking Gary's simplicity:

Let JD = Julian calendar date and day, month and year be the required Calendar date.

Then, for calendar to Julian:
d = INT((4*(JD + 32082)+3)/1461)
e = (JD + 32082) - INT((1461*d)/4)
m = INT((5*e+2)/153)

day = e - INT((153*m+2)/5) + 1
month = m + 3 - 12*INT(m/10)
year = d - 4800 + INT(m/10)

To revert from day, month, year to Julian:
a = INT(14-month)/12
y = year+4800-a
m = month + 12*a - 3

JD = day + INT((153*m+2)/5) + y*365 + INT(y/4) - 32083

(INT is integer and so you might prefer to use INTEGER-DIVIDE(x,y) if available)


soi la, soi carré
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top