I would like to read from a datetime field in SQL Server and store it as a int64, as datetime is stored as 64 bits in SQL Server. Would I do something similar to this?
DateTime dt = sqlDataReader.GetDateTime(0);
byte[] bt = BitConverter.GetBytes(dt);
// unfortunately, GetBytes() does not take DateTime as an argument
long ldt = (Convert.ToInt64(bt[0]) << 56)
+ (Convert.ToInt64(bt[1]) << 48)
+ (Convert.ToInt64(bt[2]) << 40)
+ (Convert.ToInt64(bt[3]) << 32)
+ (Convert.ToInt64(bt[4]) << 24)
+ (Convert.ToInt64(bt[5]) << 16)
+ (Convert.ToInt64(bt[6]) << 8)
+ (Convert.ToInt64(bt[7]));