Created
June 26, 2012 13:17
-
-
Save emres/2995739 to your computer and use it in GitHub Desktop.
Number of days between two dates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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