Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get seconds since epoch (1/1/1970) in VBA?

How can I get seconds since epoch (1/1/1970) in VBA?

like image 653
aF. Avatar asked Feb 13 '10 22:02

aF.


2 Answers

How about:

datediff("s",#1970/1/1#,now())
like image 57
Fionnuala Avatar answered Sep 16 '22 22:09

Fionnuala


This should run faster than the DateDiff solution:

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
like image 20
Oorang Avatar answered Sep 16 '22 22:09

Oorang