Converting date from micro-second string

kenml

Retired
Local time
Today, 16:10
Joined
Nov 4, 2009
Messages
1
I am receinving an XML date string field in micorseconds from the unix epoch (01-01-1970) and need to convert that to a mmddYYYY format. I'm somewhat of an advanced novice with Access. Could someone point me to a source to learn how to do this or provide me with something I can work with.
Any help would really be appreciated.

Regards

Kenml
 
I think I got this from Ricky Hicks. At any rate it is not mine.
Code:
' Convert Unix Epoch time (Time in seconds since Jan 1, 1970)
'
' UTS_Offset is the hours offset from GMT where you are locate
' Eastern Time (US) = -5
' Central Time (US) = -6
' Mountain Time (US) = -7
' Pacific Time (US) = -8
'
Public Function fConvertEpoch(varEpochVal As Variant, UTC_OffSet As Integer) As Variant
   Dim tmpDate As Date
   Dim StartDaylight As Date
   Dim EndDaylight As Date

   If IsNull(varEpochVal) Then Exit Function

   tmpDate = DateAdd("s", varEpochVal, #1/1/1970#)
   tmpDate = DateAdd("h", UTC_OffSet, tmpDate)

   ' Get the last day of March by subtracting one day from 4/1
   StartDaylight = DateAdd("d", -1, DateSerial(Year(tmpDate), 4, 1))

   ' Now skip to the next Sunday
   StartDaylight = DateAdd("d", 5 - Weekday(StartDaylight), StartDaylight)
   StartDaylight = DateAdd("h", 2, StartDaylight)
   EndDaylight = DateSerial(Year(tmpDate), 11, 1)

   ' Back up to the previous Sunday
   EndDaylight = DateAdd("d", -5 + Weekday(EndDaylight), EndDaylight)
   EndDaylight = DateAdd("h", 1, EndDaylight)

   If (tmpDate >= StartDaylight And tmpDate < EndDaylight) Then
      tmpDate = DateAdd("h", 1, tmpDate)
   End If

   fConvertEpoch = tmpDate

End Function
 

Users who are viewing this thread

Back
Top Bottom