title: How to convert MS excel date from float to date format in Ruby?
body: <p>Trying to parse and XLSX file using roo gem in a ruby script.</p>
  
  <p>In excel dates are stored as floats or integers in the format DDDDD.ttttt, counting from <code>1900-01-00 (00 no 01)</code>. So in order to convert a date such as 40396 - you would take <code>1900-01-00 + 40396</code> and you should get 2010-10-15, but I'm getting 2010-08-08.</p>
  
  <p>I'm using active_support/time to do calculation like so:</p>
  
  <pre><code>Time.new("1900-01-01") + 40396.days
  </code></pre>
  
  <p>Am I doing my calculation wrong or is there a bug in active support?</p>
  
  <p>I'm running ruby 1.9.3-mri on Windows 7 + latest active_support gem (3.2.1)</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I was looking at the older file in Excel with the wrong data - my script / console were pulling the right data - hence my confusion - I was doing everything right, except for using the right file!!!! Damn the all-nighters!</p>
  
  <p>Thanks to everyone replying, I will keep the question here in case somebody needs info on how to convert dates from excel using ruby.</p>
  
  <p>Also for anyone else running into this - spreadsheet gem DOES NOT support reading XLSX files at this point (v 0.7.1) properly - so I'm using roo for reading, and axlsx for writing.</p>