Re: convert unix timestamp
Quote:
Originally Posted by
Bradley2
Just incase someone else stumbles across this thread...
I was looking for similar info today. I found an old routine I'd written before, but I wasn't too certain of its results (I was worried about the 'non-day' portion of the conversion). Anyway, your function yeilds the same results as mine, so I was glad to see that, but I stumbled across something else interesting. Just out of curiousity I benchmarked the routine I had, and the one posted above (UnixTimeToDate). Results... after one million executions:
UnixTimeToDate done in 34.2 seconds.
UnixTimeToDate result : 3/13/2001 9:10:06 PM
Long2Date done in 1.5 seconds.
Long2Date result : 3/13/2001 9:10:06 PM
Huge difference in performance! (Obviously calculating a date a million times isnt normal, but . . . *shrug* thats how performance goes, gain a slice here, a slice there... and in the end it starts to add up)
So here are the routine(s) I have...
Code:
Private Function Long2Date(lngDate As Long) As Date
Long2Date = lngDate / 86400# + #1/1/1970#
End Function
Private Function Date2Long(dtmDate As Date) As Long
Date2Long = (dtmDate - #1/1/1970#) * 86400
End Function
Hello, I hope you are still around to help me with a, likely simple, problem. I'm trying to use your code to derive the date (in long string format), and then use it to create two mail messages. I'd like to use your code to get the date string, set it as a variable, and then reference that variable in each of my two messages. However, I'm not having any luck.
Could you help get me started on this? Any help from anyone is much appreciate it.
(I've tried just inserting "Date2Long", as below, and it gives an error.
"Argument not option"
".Subject = "Auto-reply to: " & item.Subject & " - SR#: " & Date2Long & " has been created.""