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" Integer full year (e.g. 2005) "YearShort" Integer year (1- or 2-digits when a string) "YearUnsigned" Integer year without a sign "YearExact" Real year including fraction "YearFraction" Real fractional part of year "YearRomanNumeral" String year using Roman numerals "ADBC" String AD or BC "CEBCE" String CE or BCE - Elements related to month include the following:
-
"Month" Integer month number (2‐digits when a string) "MonthShort" Integer month number (1‐ or 2‐digits when a string) "MonthExact" Real month including fraction "MonthFraction" Real fractional part of month "MonthName" String month name (e.g. "August") "MonthNameShort" String month name abbreviation (e.g. "Aug") "MonthNameInitial" String first letter of month name (e.g. "A") "MonthRomanNumeral" String month using Roman numerals "MonthRomanNumeralLowerCase" String month using lowercase Roman numerals - Elements related to day of the month include the following:
-
"Day" Integer day of the month (2‐digits when a string) "DayShort" Integer day of the month (1‐ or 2‐digits when a string) "DayExact" Real day including fraction "DayFraction" Real fractional part of day - Elements related to day of the week include the following:
-
"DayName" Symbol day of the week (e.g. Wednesday) "ISOWeekDay" Integer day number of week conforming to ISO-8601 (e.g. 3) "ISOWeekDayExact" Real day number of week including fraction "ISOWeekDayFraction" Real fractional day number of week "DayNameShort" String day of the week abbreviation (e.g. "Wed") "DayNameInitial" String first letter of day name (e.g. "W") "DayNameInstanceInMonth" Integer instance number of day name within the month (e.g. 2) - Elements related to hour include the following:
-
"Hour" Integer hour (2‐digits when a string) "Hour12" Integer hour on 12‐hour clock (2‐digits when a string) "Hour24" Integer hour on 24‐hour clock (2‐digits when a string) "HourShort" Integer hour (1‐ or 2‐digits when a string) "Hour12Short" Integer hour on 12‐hour clock (1‐ or 2‐digits when a string) "Hour24Short" Integer hour on 24‐hour clock (1‐ or 2‐digits when a string) "HourExact" Real hour including fraction "HourFraction" Real fractional part of hour "AMPM" String AM or PM "AMPMLowerCase" String am or pm - Elements related to minute include the following:
-
"Minute" Integer minutes (2‐digits when a string) "MinuteShort" Integer minutes (1‐ or 2‐digits when a string) "MinuteExact" Real minute including fraction "MinuteFraction" Real fractional part of minute - Elements related to second include the following:
-
"Second" Integer seconds (2-digits when a string) "SecondShort" Integer seconds (1‐ or 2‐digits when a string) "SecondExact" Real seconds including fractional seconds "SecondFraction" Real fractional part of seconds - Elements related to millisecond include the following:
-
"Millisecond" Integer milliseconds (3‐digits when a string) "MillisecondShort" Integer milliseconds (1‐, 2‐, or 3‐digit as a string) "MillisecondExact" Real millisecond including fraction "MillisecondFraction" Real fractional part of millisecond - Elements larger than a year include the following:
-
"Millennium" Integer 1000 year period beginning with year XX00 "MillenniumBeginning01" Integer 1000 year period beginning with year XX01 "Century" Integer 100 year period beginning with year XX00 "CenturyBeginning01" Integer 100 year period beginning with year XX01 "Decade" Integer 10 year period - Elements related quarters of a calendar year include:
-
"Quarter" Integer quarter number (e.g. 1) "QuarterName" String quarter of year (e.g. "Quarter 1") "QuarterNameShort" String quarter abbreviation (e.g. "Q1") - Elements related to ISO-8601 week numbers include:
-
"Week" Integer week number (2‐digits when a string) "WeekShort" Integer week number (1‐ or 2‐digits when a string) "WeekExact" Real week number including fraction "WeekFraction" Real fractional week number - Additional ISO-8601 date elements include the following:
-
"ISOWeekYear" Integer year number associated with ISO-8601 week date format "ISOYearDay" Integer day of year conforming to ISO-8601 (3-digits when a string) "ISOYearDayShort" Integer day of year (1-, 2-, or 3-digits when a string) "ISOYearDayExact" Real year day including fraction "ISOYearDayFraction" Real fractional part of year day - Time zone elements include:
-
"TimeZone" Automatic time zone expression of reference date "TimeZoneName" String common name for the time zone (e.g. "Central Standard Time") "TimeZoneNameShort" String time zone name abbreviation (e.g. "CST") "TimeZoneID" String internet time zone name (e.g. "America/Chicago") "TimeZoneOffset" Real numeric time zone offset from GMT "TimeZoneEntity" Entity entity expression representing the time zone - Additional date elements include:
-
"DayOfYear" Integer day number within the year "WeekBeginningSunday" Integer week number of year indexed on Sunday "JulianDate" Real Julian day number (e.g. 2458275.25) "CalendarType" String calendar type (e.g. "Gregorian") "Granularity" String calendar granularity "AstrologicalSign" String astrological sign (e.g. "Aries") - Possible forms include:
-
Automatic numbers, symbols, or strings, chosen automatically Integer closest integer Real real value Quantity value including units DateObject complete date object TimeObject complete time object String string Entity entity 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 allBasic Examples (1)
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:
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