CurrentDate

CurrentDate[gran]

gives the current date of the specified granularity type gran.

CurrentDate[date,gran]

gives the date of the given granularity that includes the specified date.

CurrentDate[]

gives the instant corresponding to the current date.

Details and Options

  • CurrentDate[gran] returns a DateObject expression.
  • In CurrentDate[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
    "Instant"the exact instant specified
  • For CurrentDate[daytype], the current day will be returned if it matches the specified daytype. Possible daytype specifications are: "Weekday", "WeekendDay", Monday through Sunday, "MonthFirstDay", "MonthLastDay" and "BusinessDay".
  • The following options can be given:
  • CalendarTypeAutomaticcalendar system for the result
    TimeZone$TimeZonetime zone for the result

Examples

open all close all

Basic Examples  (3)

Get a date object representing the current month:

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

Get the current hour:

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

Get the current instant:

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

Find the year associated with a given date:

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

Find the week of Albert Einstein's birth:

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

Verify that January 1, 2018 is a Monday:

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

If the given date does not match the specified day type, a message is issued:

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

Scope  (1)

Options  (2)

Properties & Relations  (2)

Introduced in 2017
(11.1)
|
Updated in 2019
(12.0)