DaysBetween

As of Version 10.0, calendar functionality is built into the Wolfram Language

DaysBetween[{year1,month1,day1},{year2,month2,day2}]
gives the number of days between the dates {year1,month1,day1} and {year2,month2,day2}.

DaysBetween[{year1,month1,day1,hour1,minute1,second1},{year2,month2,day2,hour2,minute2,second2}]
gives the number of days between the given dates.

更多信息更多信息

范例范例打开所有单元关闭所有单元

基本范例  (7)基本范例  (7)

In[1]:=
Click for copyable input

The number of days between consecutive days is 1:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

The number of days between the same date is 0:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

If the second date is earlier than the first date, then a negative result is returned:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

John F. Kennedy's presidency is referred to as lasting 1000 days:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

Hours, minutes, and seconds do not affect DaysBetween:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

In the default (Western/American) calendar, 11 days were deleted in September 1752:

In[2]:=
Click for copyable input
Out[2]=
In[1]:=
Click for copyable input

In the default (Western/American) calendar, 1752 had 355 days:

In[2]:=
Click for copyable input
Out[2]=
Translate this page: