sprocket
sprocket

Reputation: 21

Converting Julian Days in VB

I need to convert a set of Julian Days into proper Date Time format dd/mm/yyyy HH:MM:SS

Problem seems to be that they are Julian Days FROM a certain date, im assuming the standard 1970? Below is my code:

Function:

    Public Function ConvertJulianDate(ByVal JulianDate As Double) As DateTime
    Dim julianRoot As DateTime


    julianRoot = "01/01/1970 00:00:00"

    ConvertJulianDate = julianRoot.AddDays(JulianDate)

    End Function

Call (I've hard coded a value in for now):

     Dim result As DateTime
     Dim JulianDate As Double
     JulianDate = 140.708368

     result = Utilities.ConvertJulianDate(JulianDate)

This gives me the value "5/21/1970 5:00:02 PM"

It seems the year is off as I know the data is from 2011. Can anyone guide me?

Upvotes: 1

Views: 2957

Answers (1)

sprocket
sprocket

Reputation: 21

After a heap of research into Julian Date formats, I realise I need to know the correct julianRoot - without an epoch relevant to the Julian Day, the value of the Year is useless.

Upvotes: 0

Related Questions