I have a "DateTime" var with the current date (DateTime.Now). I can convert this to a OADate-Format (41392,524432) as example. But how I can convert this, that I'm just getting the time without the date? For example 1 minute and 4 seconds (01:04) are 0,04444444 in this format.
Since MSDN states that:
An OLE Automation date is implemented as a floating-point number whose integral component is the number of days before or after midnight, 30 December 1899
you presumably want to use that as your base date:
DateTime oaBaseDate = new DateTime(1899,12,30);
double result = oaBaseDate.Add(DateTime.Now.TimeOfDay).ToOADate();
or if you don't like magic numbers (magic dates), the equivalent:
DateTime oaBaseDate = DateTime.FromOADate(0);
double result = oaBaseDate.Add(DateTime.Now.TimeOfDay).ToOADate();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With