Skip to content

Instantly share code, notes, and snippets.

@emres
Created June 26, 2012 13:17
Show Gist options
  • Save emres/2995739 to your computer and use it in GitHub Desktop.
Save emres/2995739 to your computer and use it in GitHub Desktop.
Number of days between two dates
(defun number-of-days-between-dates (date1 date2)
"Returns the number of days between two dates.
Usage:
(number-of-days-between-dates \"yyyy-mm-dd\" \"yyyy-mm-dd\")
Or
M-x number-of-days-between-dates"
(interactive "sStart Date (in yyyy-mm-dd format): \nsEnd date (in yyyy-mm-dd format): \n")
(message
(number-to-string
(abs
(- (time-to-day-in-year (date-to-time (concat date1 " 00:00:00")))
(time-to-day-in-year (date-to-time (concat date2 " 00:00:00"))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment