Julian date to a format dd/mm/yyyy

Posted on 2006-04-06
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

    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

    LVL 44

    Expert Comment

    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")
    LVL 31

    Expert Comment

    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

    LVL 15

    Accepted Solution


    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:

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

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now