Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Julian date to a format dd/mm/yyyy

Posted on 2006-04-06
Medium Priority
Last Modified: 2012-06-21
I have a formula to obtain the Julian date that is the follow:

y = year + 4800 - a
m = month + 12a - 3

JD = day + (153m +23)/5 + 365y + y/4 - 32045

Has anyone used this function before¿?

And now to obtain the function that converts a date julian to string format normal date¿?
Question by:1469
LVL 44

Expert Comment

ID: 16393073
what programming language are you using?  

subtract 2451700 (which is the JD for Jan 1, 2000) from the JD that you want to convert, and then add (or subtract as the case may be) that many days from Jan 1, 2000 to get the date the corresponds to the JD that you have.


Author Comment

ID: 16393212
LVL 44

Expert Comment

ID: 16393852
You have asked this precise question elsewhere (Math & Science), and that violates the EE rule about offering more than 500 points TOTAL for a question.  You have also accepted the answer provided in the other question, so there seems to be very little to be served by offereing an answer here.

To get the Current Date from a give JD, in VB or VBA:

Dim strCurentDate as string
strCurrentDate = Format(DateAdd("d", JD - 2451700, #Jan 1, 2000#), "MMM dd, YYYY")
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 31

Expert Comment

ID: 16395026
You might be able to get both questions cut down to 250 points each.  I for one am interested in both the programming angle and the historical angle.
LVL 31

Expert Comment

ID: 16395095
LVL 15

Accepted Solution

Ralf Klatt earned 750 total points
ID: 16397436

This function will return the exact Julian Date for a given vbDate entry:

'The Function:
Public Function JulianDate(ByVal datDate As Date) As Double
    Dim GGG
    Dim DD, MM, YY
    Dim S, A
    Dim JD, J1
    Let MM = Month(datDate)
    Let DD = Day(datDate)
    Let YY = Year(datDate)
    Let GGG = 1
    If (YY <= 1585) Then
        GGG = 0
    End If
    Let JD = -1 * Int(7 * (Int((MM + 9) / 12) + YY) / 4)
    Let S = 1
    If ((MM - 9) < 0) Then
        S = -1
    End If
    Let A = Abs(MM - 9)
    Let J1 = Int(YY + S * Int(A / 7))
    Let J1 = -1 * Int((Int(J1 / 100) + 1) * 3 / 4)
    Let JD = JD + Int(275 * MM / 9) + DD + (GGG * J1)
    Let JD = JD + 1721027 + 2 * GGG + 367 * YY
    If ((DD = 0) And (MM = 0) And (YY = 0)) Then
      MsgBox "Please enter a meaningful date!"
      Let JulianDate = JD
    End If
    Exit Function
    MsgBox "MainModule.JulianDate()"
    Exit Function
End Function

'How to call the function:
Private Sub Command1_Click()
    MsgBox (JulianDate(Now))
End Sub

To verify the results of the suggested piece of code you might check the generated result using the Julian Date Converter at: http://aa.usno.navy.mil/data/docs/JulianDate.html

PS: I'll post this answer at both channels -> I think it's worth it! ... ;-)
Best regards,

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question