Convert to Date
-
Since I don't know of any 5 digit numbers that represents a date, what does this number represent? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Since I don't know of any 5 digit numbers that represents a date, what does this number represent? RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
it actually a julian date format 10204120 all i need is to be able to convert last three digits 325 into months and day format in this case it's 04/31
Hey this should do it
Dim JulDate As Long Dim TempDate As String Dim FinalDate As Date JulDate = 100015 'Your Julian Date TempDate = "01/01/" If JulDate > 99999 Then TempDate = TempDate + Mid(LTrim(Str(JulDate)), 2, 2) Else TempDate = TempDate + Mid(LTrim(Str(JulDate)), 2) End If FinalDate = DateAdd("d", Val(Mid(Str(JulDate) - 1, 3)), TempDate)
then use
Debug.WriteLine(FinalDate, Format(FinalDate, "mm/dd/yyyy"))
or
MsgBox(FinalDate)
to output it to screen so...
Private Sub Button1\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim JulDate As Long Dim TempDate As String Dim FinalDate As Date JulDate = 100015 'Your Julian Date TempDate = "01/01/" If JulDate > 99999 Then TempDate = TempDate + Mid(LTrim(Str(JulDate)), 2, 2) Else TempDate = TempDate + Mid(LTrim(Str(JulDate)), 2) End If FinalDate = DateAdd("d", Val(Mid(Str(JulDate) - 1, 3)), TempDate) MsgBox(FinalDate) End Sub
should do it for you. Hope this helps Chris
-
it actually a julian date format 10204120 all i need is to be able to convert last three digits 325 into months and day format in this case it's 04/31
"Julian" dates are a representation of the number of days since a base date. In Excel for Windows, this would be Jan 1, 1900 (for the Mac, it would be Jan 1, 1904). These numbers are really just serial numbers, but what date this number represents is entirely up to the application/system that issued it. The .NET Framework uses a structure that can represent any date/time from midnight on Jan 1, 0001 to Midnight Dec 31, 9999, measured in ticks (100 milliseconds). You can use this structure to try and parse your date/time number into a .NET Framework date/time, then get the month and day from that. Look into
DateTime.FromOADate
(OLE Automation dates), andDateTime.FromFileTime
(filesystem date/time format). RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome