PreviousDate

PreviousDate[gran]

gives the previously occurring date of the specified granularity type gran.

PreviousDate[date,gran]

gives the previous date of the given granularity relative to the specified date.

Details and Options

  • PreviousDate[gran] returns a DateObject expression.
  • In PreviousDate[gran], the granularity type gran can be any of the following:
  • "Millennium"1000-year period beginning with year XX00
    "MillenniumBeginning01"1000-year period beginning with year XX01
    "Century"100-year period beginning with year XX00
    "CenturyBeginning01"100-year period beginning with year XX01
    "Decade"10-year period including the date
    "Year"year including the date
    "Quarter"3-month quarter including the date
    "Month"month including the date
    "Week"week beginning Monday including the date
    "WeekBeginningSunday"week beginning Sunday including the date
    "Day"day including the date
    "Hour"hour including the date
    "Minute"minute including the date
    "Second"second including the date
  • The following options can be given:
  • CalendarTypeAutomaticcalendar system for the result
    TimeZone$TimeZonetime zone for the result

Examples

open allclose all

Basic Examples  (2)

Get a date object representing the previous month:

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

Get the date object for the previous hour:

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

Get the week before a given date:

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

Find the day before the fall of Saigon:

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

Scope  (1)

Options  (2)

Properties & Relations  (1)

See Also

CurrentDate  NextDate  Yesterday  DateObject  DatePlus

Introduced in 2017
(11.1)