Converting a date time value to a timestamp

I have a web page that has a textbox for users to enter a datestring to check against a database. The database that I am running my query against has datetime values set at minutes since 12/31/1899 and that returns a timestamp. What I’d like to do in my code is to convert my textbox entry into minutes since 12/31/1899. Does anyone have an easy way to do that?

Thank you

Doug

Assuming that users enter a valid date, try this (approximate code)


var date=DateTime.Parse(input.Text); //replace with whatever string provided by user
var time=date.Substract(new DateTime(1899,12,31));
//total minutes 
var minutes=time.TotalMinutes;