title: Duplicating Excel's representation of Dates in Julia
body: <p>In Julia I need to convert numbers to <code>DateTime</code> in the same manner as Microsoft Excel.</p>
  
  <p>In Excel, today's date of 23-Sep-2019 is represented by 43731 and 6pm this afternoon by 43731.75. I can ignore the fact that <a href="https://support.microsoft.com/en-us/help/214326/excel-incorrectly-assumes-that-the-year-1900-is-a-leap-year" rel="nofollow noreferrer">Excel incorrectly assumes that 1900 is a leap year</a> since all my data is safely beyond that point. Millisecond accuracy is sufficient.</p>
  
  <p>The code below seems to work, but is there a better way?</p>
  
  <pre><code>function exceldatetodate(exceldate::Integer)
      Dates.Date(1899, 12, 30) + Dates.Day(exceldate)
  end
  function exceldatetodate(exceldate::Real)
      t,d = modf(exceldate)
      Dates.Date(1899, 12, 30) + Dates.Day(d) + Dates.Millisecond(floor(t * 86400000))
  end
  
  julia&gt; exceldatetodate(43731)
  2019-09-23
  
  julia&gt; exceldatetodate(43731.75)
  2019-09-23T18:00:00
  </code></pre>