DateValue

DateValue["elem"]
gives the specified element of the current date and time.

DateValue[{"elem1","elem2",}]
gives a list of the specified elements of the current date and time.

DateValue[date,elem]
gives the specified element of the specified date.

DateValue[date,elem,form]
gives the result in the specified form.

DetailsDetails

  • Possible elements include:
  • "Year"full year (e.g. 2015)
    "YearShort"2digit year (e.g. 15)
    "Quarter"quarter number (e.g. 1)
    "QuarterName"quarter of year (e.g. "Quarter 1")
    "QuarterNameShort"quarter of year in short form (e.g. "Q1")
    "Month"month number (e.g. 8)
    "MonthName"month name (e.g. "August")
    "MonthNameShort"month name in short form (e.g. "Aug")
    "MonthNameInitial"first letter of month name (e.g. "A")
    "DayName"day of the week (e.g. Wednesday)
    "DayNameShort"day of the week in short form (e.g. "Wed")
    "DayNameInitial"first letter of day name (e.g. "W")
    "Day"day of the month (e.g. 9)
    "Hour"hour on 12- or 24-hour clock, based on system preferences
    "Hour12"hour on 12hour clock (e.g. 7)
    "Hour24"hour on 24hour clock (e.g. 19)
    "AMPM"AM or PM
    "AMPMLowerCase"am or pm
    "Minute"minute (e.g. 15)
    "Second"integer seconds
    "SecondExact"seconds including fractions
    "Millisecond"millisecond
    "CalendarType"calendar type (e.g. "Gregorian")
    "TimeZone"time zone as offset from GMT
  • Possible forms include:
  • Automaticnumbers, symbols, or strings, chosen automatically
    Integerclosest integer
    Realreal value
    Quantityvalue including units
    DateObjectcomplete date object
    TimeObjectcomplete time object
    Stringstring
  • In DateValue[date,], date can be specified as a DateObject or TimeObject, or results from DateList, DateString, or AbsoluteTime.
  • DateValue[date,spec,DateObject] can be used to give a DateObject that is granular only down to the level (e.g. day, month, year) specified by spec.
  • DateValue[GeoPosition[{lat,long,h,t}]] gives a DateObject the time specified by t.
  • DateValue accepts a list of DateObject or TimeObject date specifications.

ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

Get the current year:

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

Get multiple elements from the current date:

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

Get the month name from a given date:

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

Find the current offset as a Quantity:

In[4]:=
Click for copyable input
Out[4]=
Introduced in 2014
(10.0)