gives the number of days from date1 to date2.


gives the difference between date1 and date2 in the specified unit.


gives the difference as a list with elements corresponding to the successive "uniti".

Details and Options

  • DateDifference returns a Quantity object.
  • Dates can be specified in the following forms:
  • DateObject[]date object
    {y,m,d}year, month, day
    {y,m}the first day of the specified month
    {y}January 1 of the year y
    "string"date as a string ("Jan. 1, 2000")
    {y,m,d,h,m,s}precise time
    timeabsolute time specification
  • Possible units are "Year", "Quarter", "Month", "Week", "Day", "Hour", "Minute", "Second".
  • {y,m,d} is taken to be equivalent to {y,m,d,0,0,0} etc.
  • DateDifference takes the following option:
  • DayCountConvention"ActualActual"counting convention by which the difference is computed
  • DateDifference enumerated in days follows the day count convention, regardless of the magnitude of the difference.
  • DateDifference[date2] gives the fractional number of days from the current time until date2.


open allclose all

Basic Examples  (4)

Give the number of days between January 1 and July 4:

Use dates specified in {y,m,d} form:

Find a date difference in units of weeks:

If the second date is before the first, the date difference is negative:

Scope  (6)

Date Formats  (3)

Give dates in any format supported by DateString:

Different date specifications can be mixed:

DateDifference can use times given in {y,m,d,h,m,s} format:

Units  (3)

Find the number of hours between two dates:

Find the number of years between two dates:

Find the difference between two dates in months and days:

Options  (4)

DayCountConvention  (2)

Day count conventions differ with respect to the count applied to the last days of the month:

Compute the difference in years, subject to a day count convention:

CalendarType  (2)

Compute a date difference in the Jewish calendar:

Islamic years are shorter than Gregorian years:

Applications  (2)

Find the number of years, months, and days since the beginning of the year 2000:

There are always 184 days between March 21 and September 21:

There are 181 days between September 21 and March 21 of the following year, if it is not a leap year:

There are 182 days if the following year is a leap year:

Properties & Relations  (1)

DatePlus adds time units to dates, while DateDifference computes units between dates:

The inverse relationship:

Possible Issues  (2)

Date strings can be ambiguous:

Use DateObject to disambiguate between different interpretations:

In previous Wolfram Language releases, DateDifference returned purely numerical results. This legacy behavior can be enabled with SetSystemOptions:

Quantity results can be re-enabled by setting the same system option value to True:

Wolfram Research (2007), DateDifference, Wolfram Language function, (updated 2014).


Wolfram Research (2007), DateDifference, Wolfram Language function, (updated 2014).


@misc{reference.wolfram_2020_datedifference, author="Wolfram Research", title="{DateDifference}", year="2014", howpublished="\url{}", note=[Accessed: 17-January-2021 ]}


@online{reference.wolfram_2020_datedifference, organization={Wolfram Research}, title={DateDifference}, year={2014}, url={}, note=[Accessed: 17-January-2021 ]}


Wolfram Language. 2007. "DateDifference." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014.


Wolfram Language. (2007). DateDifference. Wolfram Language & System Documentation Center. Retrieved from