How do I convert a date to unix-format

S

Soren

Hi

I need a VBA function to convert a date (e.g. 06-28-2004)
to UNIX-format (e.g. 1088433541)

Can anyone help me?

Thanks
Soren
 
J

Jonathan West

Soren said:
Hi

I need a VBA function to convert a date (e.g. 06-28-2004)
to UNIX-format (e.g. 1088433541)

Can anyone help me?

The Unix date format is the number of seconds since 1/1/1970. On that basis,
this should give you the correct value

Function UnixDate(d As Date) As Long
UnixDate = DateDiff("s", #1/1/1970#, d)
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top