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.

Details

  • Elements related to year include the following:
  • "Year"full year (e.g. 2005)
    "YearShort"2digit year (e.g. 05)
    "YearExact"year including fraction
    "YearFraction"fractional part of year
    "ISOYear"year conforming to ISO-8601 (e.g. 0199)
    "YearUnsigned"year without a sign
    "YearRomanNumeral"year using Roman numerals
    "ADBC"AD or BC
    "CEBCE"CE or BCE
  • Elements related to month include the following:
  • "Month"2digit month number (e.g. 08)
    "MonthShort"1 or 2digit month number (e.g. 8)
    "MonthExact"month including fraction
    "MonthFraction"fractional part of month
    "MonthName"month name (e.g. "August")
    "MonthNameShort"month name in short form (e.g. "Aug")
    "MonthNameInitial"first letter of month name (e.g. "A")
    "MonthRomanNumeral"month using Roman numerals
    "MonthRomanNumeralLowerCase"month using lowercase Roman numerals
  • Elements related to day of the month include the following:
  • "Day"2digit day of the month (e.g. 09)
    "DayShort"1 or 2digit day of the month (e.g. 9 or 29)
    "DayExact"day including fraction
    "DayFraction"fractional part of day
  • Elements related to day of the week include the following:
  • "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")
    "ISOWeekDay"day number of week conforming to ISO-8601 (e.g. 4 for Thursday)
    "ISOWeekDayExact"day number of week including fraction
    "ISOWeekDayFraction"fractional day number of week
  • Elements related to hour include the following:
  • "Hour"2digit hour based on system preferences
    "Hour12"2digit hour on 12hour clock (e.g. 07)
    "Hour24"2digit hour on 24hour clock (e.g. 19)
    "HourShort"1 or 2digit hour based on system preferences
    "Hour12Short"1 or 2digit hour on 12hour clock (e.g. 7)
    "Hour24Short"1 or 2digit hour on 24hour clock (e.g. 7, 19)
    "HourExact"hour including fraction
    "HourFraction"fractional part of hour
    "AMPM"AM or PM
    "AMPMLowerCase"am or pm
  • Elements related to minute include the following:
  • "Minute"2digit minute (e.g. 05)
    "MinuteShort"1 or 2digit minute (e.g. 5 or 35)
    "MinuteExact"minute including fraction
    "MinuteFraction"fractional part of minute
  • Elements related to second include the following:
  • "Second"2digit seconds
    "SecondShort"1 or 2digit seconds
    "SecondExact"seconds including fractions
    "SecondFraction"fractional part of second
    "Millisecond"3digit milliseconds
    "MillisecondShort"1, 2, or 3digit milliseconds
    "MillisecondExact"millisecond including fraction
    "MillisecondFraction"fractional part of millisecond
  • Elements larger than a year include the following:
  • "Millennium"1000 year period beginning with year XX00
    "MillenniumUnsigned"unsigned millennium
    "MillenniumBeginning01"1000 year period beginning with year XX01
    "MillenniumBeginning01Unsigned"unsigned millennium beginning with year XX01
    "Century"100 year period beginning with year XX00
    "CenturyUnsigned"unsigned century
    "CenturyBeginning01"100 year period beginning with year XX01
    "CenturyBeginning01Unsigned"unsigned century beginning with year XX01
    "Decade"10 year period
    "DecadeUnsigned"unsigned decade
  • Elements related to multiple date elements include the following:
  • "Quarter"quarter number (e.g. 1)
    "QuarterName"quarter of year (e.g. "Quarter 1")
    "QuarterNameShort"quarter of year in short form (e.g. "Q1")
    "Week"2digit week number (e.g. 02)
    "WeekShort"1 or 2digit week number (e.g. 2)
    "WeekExact"week number including fraction
    "WeekFraction"fractional week number
  • Additional ISO-8601 date elements include the following:
  • "ISOYearDay"3digit day of the year conforming to ISO-8601 (e.g. 094)
    "ISOYearDayShort"1, 2 or 3digit day of the year (e.g. 94)
    "ISOYearDayExact"year day including fraction
    "ISOYearDayFraction"fractional part of year day
  • Additional date elements include:
  • "JulianDate"Julian day number (e.g. 2458275)
    "CalendarType"calendar type (e.g. "Gregorian")
    "TimeZone"time zone of referene date
    "Granularity"calendar granularity
  • 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 of the time specified by t.
  • DateValue accepts a list of DateObject or TimeObject date specifications.

Examples

open all close all

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 "TimeZone" offset as a Quantity:

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

Scope  (4)

Possible Issues  (2)

Introduced in 2014
(10.0)