Skip to content

Instantly share code, notes, and snippets.

@gaute
Last active August 29, 2015 14:15
Show Gist options
  • Save gaute/500f0b42f1f167a92420 to your computer and use it in GitHub Desktop.
Save gaute/500f0b42f1f167a92420 to your computer and use it in GitHub Desktop.
Convert Microsoft (Excel) timestamp to ISO
(defun microsoft-date-to-iso (microsoft-date)
(format-time-string "%Y-%m-%d %H:%M:%S%z" (days-to-time (- (string-to-number microsoft-date) 25569))))
@gaute
Copy link
Author

gaute commented Feb 17, 2015

Microsoft timestamp: 39962.5493055556

39962 is the number of days since December 30, 1899. The fraction part is the elapsed fraction of the day. (0.5 means 12:00, 0.75 means 18:00, etc.)

Emacs' days_to_time converts the number of days since January 1, 1970, including the fraction part.

To convert, we subtract 25569, which is the number of days between 1970-01-01 and 1899-12-30. The fraction part is left alone.

Returned ISO time: 2009-05-29 15:11:00+0200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment