Search This Blog

Tuesday, April 24, 2012

Convert a DateTime to a BIGINT or 64bit Integer

Okay, so I have a stored procedure that is creating an Timestamp from a date field using: CONVERT(BIGINT,[UpdatedDate])

So I'm using Linq, lambda expressions, IList to parse and filter the resultset from SQL server.
I need all of the records affected within the last 90 days but the UpdatedDate is transformed into a BIGINT
from 20.12-04-04 05:37:28.717 to 41001.  Now I needed a way to convert DateTime.Now into a 64bit integer.  Convert.ToInt64(DateTime.Now) throws a typeException error.

The Answer: DateTime.Now.ToOADate():
 DateTime.Now {4/24/2012 8:49:19 AM}
DateTime.Now.ToOADate() 41023.367304120373

No comments: