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

Julian Date

Status
Not open for further replies.

darude

Programmer
Jun 23, 2003
138
US
Hi Again,
Does anyone know if there is a function that converts the regular date to julian date?

Thanks
 
While not the most graceful....

' ************************

Public Function JDate(dteDate As Date) As Integer

Select Case Month(dteDate)
Case 1: JDate = Day(dteDate)
Case 2: JDate = 31 + Day(dteDate)
Case 3: JDate = 31 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 4: JDate = 62 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 5: JDate = 92 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 6: JDate = 123 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 7: JDate = 153 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 8: JDate = 184 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 9: JDate = 215 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 10: JDate = 245 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 11: JDate = 276 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
Case 12: JDate = 306 + DaysInMonth(DateSerial(Year(dteDate), 2, 1)) + Day(dteDate)
End Select

End Function

Public Function DaysInMonth(dtmDate As Date) As Integer

Dim dtmTemp As Date

dtmTemp = DateAdd("d", -1, DateSerial(Year(dtmDate), Month(dtmDate) + 1, 1))
DaysInMonth = CInt(Format(dtmTemp, "dd"))

End Function

****************************
When the human body encounters disease it raises its temperature making it uncomfortable not only for the body but also for the disease. So it global warming the Earth's way of saying we are not wanted?

Robert L. Johnson III
MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top