Is it possible to convert dates, like e.g.

date = "2018-02-15";

to be represented by whole number increments starting with 30 December 1899, midnight UTC? I believe this is called DATE format in Windows. Maybe there is an internal Mathematica function that does this?

  • $\begingroup$ hoe about DateObject[{2018, 02, 15}] $\endgroup$ – J42161217 Oct 18 '18 at 14:48
  • $\begingroup$ @J42161217 Sorry, this does not return an integer number of days since 30 December 1899... $\endgroup$ – Kagaratsch Oct 18 '18 at 14:52
  • 3
    $\begingroup$ You could simply use AbsoluteTime[<date>] or DayCount["12/30/1899", "02/15/2018"] $\endgroup$ – user42582 Oct 18 '18 at 15:01

Easiest way to avoid the units system would be something like

(AbsoluteTime["2018-02-15"] - AbsoluteTime["1899-12-30"])/86400

(untested, as I am on gedanken Mathematica)


So far I have hacked together the following:

  DateDifference[{1899, 12, 30, 0, 0, 0.`}, 
   DateList[ date ]]] // Round


Can this be made quicker, to be used with large sets of dates efficiently?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.