And, this gets the Julian Date-Time
VB Code:
Option Explicit Private Sub Form_Load() MsgBox CalcJDate(#10/9/1995 12:00:00 PM#) 'MsgBox CalcJDate(Date) Unload Me End Sub Private Function CalcJDate(ByVal nDateTime As Date) As Double Dim mm As Double Dim dd As Double Dim yy As Double Dim hr As Double Dim mn As Double Dim gg As Double Dim s As Double Dim jd As Double Dim a As Double Dim j1 As Double mm = Month(nDateTime) dd = Day(nDateTime) yy = Year(nDateTime) hr = Hour(nDateTime) mn = Minute(nDateTime) hr = hr + (mn / 60) gg = 1 If yy < 1585 Then gg = 0 End If jd = -1 * ((7 * ((mm + 9) / 12) + yy) / 4) s = 1 If (mm - 9) < 0 Then s = -1 End If a = Abs(mm - 9) j1 = (yy + s * (a / 7)) j1 = -1 * (((j1 / 100) + 1) * 3 / 4) jd = jd + (275 * mm / 9) + dd + (gg * j1) jd = jd + 1721027 + 2 * gg + 367 * yy - 0.5 jd = jd + (hr / 24) CalcJDate = jd End Function
Why not use the Date-Time Picker to let the user select a date?




Reply With Quote