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"Integerfull year (e.g. 2005)
    "YearShort"Integeryear (1- or 2-digits when a string)
    "YearUnsigned"Integeryear without a sign
    "YearExact"Realyear including fraction
    "YearFraction"Realfractional part of year
    "YearRomanNumeral"Stringyear using Roman numerals
    "ADBC"StringAD or BC
    "CEBCE"StringCE or BCE
  • Elements related to month include the following:
  • "Month"Integermonth number (2digits when a string)
    "MonthShort"Integermonth number (1 or 2digits when a string)
    "MonthExact"Realmonth including fraction
    "MonthFraction"Realfractional part of month
    "MonthName"Stringmonth name (e.g. "August")
    "MonthNameShort"Stringmonth name abbreviation (e.g. "Aug")
    "MonthNameInitial"Stringfirst letter of month name (e.g. "A")
    "MonthRomanNumeral"Stringmonth using Roman numerals
    "MonthRomanNumeralLowerCase"Stringmonth using lowercase Roman numerals
  • Elements related to day of the month include the following:
  • "Day"Integerday of the month (2digits when a string)
    "DayShort"Integerday of the month (1 or 2digits when a string)
    "DayExact"Realday including fraction
    "DayFraction"Realfractional part of day
  • Elements related to day of the week include the following:
  • "DayName"Symbolday of the week (e.g. Wednesday)
    "ISOWeekDay"Integerday number of week conforming to ISO-8601 (e.g. 3)
    "ISOWeekDayExact"Realday number of week including fraction
    "ISOWeekDayFraction"Realfractional day number of week
    "DayNameShort"Stringday of the week abbreviation (e.g. "Wed")
    "DayNameInitial"Stringfirst letter of day name (e.g. "W")
    "DayNameInstanceInMonth"Integerinstance number of day name within the month (e.g. 2)
  • Elements related to hour include the following:
  • "Hour"Integerhour (2digits when a string)
    "Hour12"Integerhour on 12hour clock (2digits when a string)
    "Hour24"Integerhour on 24hour clock (2digits when a string)
    "HourShort"Integerhour (1 or 2digits when a string)
    "Hour12Short"Integerhour on 12hour clock (1 or 2digits when a string)
    "Hour24Short"Integerhour on 24hour clock (1 or 2digits when a string)
    "HourExact"Realhour including fraction
    "HourFraction"Realfractional part of hour
    "AMPM"StringAM or PM
    "AMPMLowerCase"Stringam or pm
  • Elements related to minute include the following:
  • "Minute"Integerminutes (2digits when a string)
    "MinuteShort"Integerminutes (1 or 2digits when a string)
    "MinuteExact"Realminute including fraction
    "MinuteFraction"Realfractional part of minute
  • Elements related to second include the following:
  • "Second"Integerseconds (2-digits when a string)
    "SecondShort"Integerseconds (1 or 2digits when a string)
    "SecondExact"Realseconds including fractional seconds
    "SecondFraction"Realfractional part of seconds
  • Elements related to millisecond include the following:
  • "Millisecond"Integermilliseconds (3digits when a string)
    "MillisecondShort"Integermilliseconds (1, 2, or 3digit as a string)
    "MillisecondExact"Realmillisecond including fraction
    "MillisecondFraction"Realfractional part of millisecond
  • Elements larger than a year include the following:
  • "Millennium"Integer1000 year period beginning with year XX00
    "MillenniumBeginning01"Integer1000 year period beginning with year XX01
    "Century"Integer100 year period beginning with year XX00
    "CenturyBeginning01"Integer100 year period beginning with year XX01
    "Decade"Integer10 year period
  • Elements related quarters of a calendar year include:
  • "Quarter"Integerquarter number (e.g. 1)
    "QuarterName"Stringquarter of year (e.g. "Quarter 1")
    "QuarterNameShort"Stringquarter abbreviation (e.g. "Q1")
  • Elements related to ISO-8601 week numbers include:
  • "Week"Integerweek number (2digits when a string)
    "WeekShort"Integerweek number (1 or 2digits when a string)
    "WeekExact"Realweek number including fraction
    "WeekFraction"Realfractional week number
  • Additional ISO-8601 date elements include the following:
  • "ISOWeekYear"Integeryear number associated with ISO-8601 week date format
    "ISOYearDay"Integerday of year conforming to ISO-8601 (3-digits when a string)
    "ISOYearDayShort"Integerday of year (1-, 2-, or 3-digits when a string)
    "ISOYearDayExact"Realyear day including fraction
    "ISOYearDayFraction"Realfractional part of year day
  • Time zone elements include:
  • "TimeZone"Automatictime zone expression of reference date
    "TimeZoneName"Stringcommon name for the time zone (e.g. "Central Standard Time")
    "TimeZoneNameShort"Stringtime zone name abbreviation (e.g. "CST")
    "TimeZoneID"Stringinternet time zone name (e.g. "America/Chicago")
    "TimeZoneOffset"Realnumeric time zone offset from GMT
    "TimeZoneEntity"Entityentity expression representing the time zone
  • Additional date elements include:
  • "DayOfYear"Integerday number within the year
    "WeekBeginningSunday"Integerweek number of year indexed on Sunday
    "JulianDate"RealJulian day number (e.g. 2458275.25)
    "CalendarType"Stringcalendar type (e.g. "Gregorian")
    "Granularity"Stringcalendar granularity
    "AstrologicalSign"Stringastrological sign (e.g. "Aries")
  • Possible forms include:
  • Automaticnumbers, symbols, or strings, chosen automatically
    Integerclosest integer
    Realreal value
    Quantityvalue including units
    DateObjectcomplete date object
    TimeObjectcomplete time object
    Stringstring
    Entityentity object
  • In DateValue[date,elem,form], some form specifications may not be supported in all elements elem.
  • 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 allclose all

Basic Examples  (1)

Get the current year:

Get multiple elements from the current date:

Get the month name from a given date:

Find the current "TimeZone" offset as a Quantity:

Scope  (4)

DateValue accepts all valid date and time specifications:

DateValue returns the time component of a GeoPosition argument:

DateValue also accepts a list of DateObject and TimeObject date specifications:

The ISO-8601 week begins on Monday and ends on Sunday:

Possible Issues  (2)

Some elements are not extractable for different inputs:

Not all types are valid for every element:

Wolfram Research (2014), DateValue, Wolfram Language function, https://reference.wolfram.com/language/ref/DateValue.html (updated 2018).

Text

Wolfram Research (2014), DateValue, Wolfram Language function, https://reference.wolfram.com/language/ref/DateValue.html (updated 2018).

CMS

Wolfram Language. 2014. "DateValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2018. https://reference.wolfram.com/language/ref/DateValue.html.

APA

Wolfram Language. (2014). DateValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DateValue.html

BibTeX

@misc{reference.wolfram_2024_datevalue, author="Wolfram Research", title="{DateValue}", year="2018", howpublished="\url{https://reference.wolfram.com/language/ref/DateValue.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_datevalue, organization={Wolfram Research}, title={DateValue}, year={2018}, url={https://reference.wolfram.com/language/ref/DateValue.html}, note=[Accessed: 21-November-2024 ]}