I want to convert the DateTime.Now to a double number...However, it seems
Convert.ToString(DateTime.Now) does not work...
Any method
I want to convert the DateTime.Now to a double number...However, it seems
Convert.ToString(DateTime.Now) does not work...
Any method
How to convert DateTime to Double?
Anonomuys
Hi
I I think this snippet shoul do the trick:-
private void ConvertDate_To_Double_Click(object sender, EventArgs e)
{
try {
double date = Convert.ToSingle(DateTime.Now.ToOADate());
MessageBox.Show("Date to Double is: " + date.ToString());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
hope this helps
Khalnayak
So that means I can calculate the value I get from DateTime.Now.ToOADate() and return the format of the time I like.
Thanks!
Frank Carr
-Dave
Alexnaldo Santos
If you wish to convert a DateTime to a double you can use the method ToOADate of the structure DateTime:
DateTime.Now.ToOADate();
Thibaut Barrère
You could use DateTime.Now.Ticks (a long): The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001.
The DateTime.Now.ToOADate() would return an OLE Automation date. An OLE Automation date is implemented as a floating-point number whose value is the number of days from midnight, 30 December 1899.
-Ernst