Convert a DateTime to byte[]

  • Thread starter Thread starter Fabio
  • Start date Start date
F

Fabio

Hi all!

A simple question: I need to convert a DateTime var to a byte[] (or to a
Int64).

How?

Thanks!
 
Hi all!

A simple question: I need to convert a DateTime var to a byte[] (or to a
Int64).

How?

Thanks!

datetime.ToOaDate() returns an int, maybe that helps?

greetz,
Leon
 
no - it returns a double; if you wanted to go down this route, .Ticks might
be a reasonable choice...

Marc
 
byte[] b = BitConverter.GetBytes( theDateTime.Ticks);

Thanks to all, this is the right way in, and this the way out:

DateTime d = DateTime.FromBinary(BitConverter.ToInt64(b, 0))
 
Back
Top