Oops. There was a bug in the version I first posted, and the date came out
one day too high.
Try this instead:
' Receives a date as a string in format "YDDD", where Y is the last digit
' of the year, and DDD is the day number within the year; returns a
DateTime
' object with specified date. E.g., "4365" is December 31, 2004.
Public Function ToDateTime(ByVal theDate As String) As DateTime
' A DateTime as of the first day of the specified year
Dim dt as new DateTime(CInt("200" + theDate.Substring(0, 1)), 1, 1)
' Add the specified number of days and return the resulting DateTime
object.
return dt.AddDays(CInt(theDate.Substring(1, 3)) - 1)
End Function
This assumes leading zeroes in the day part of the date string. For
instance, January 1, 2004 would be "4001".
Sorry 'bout that.
Tom