DateGranularity

DateGranularity

is an option that determines the calendar granularity of generated dates.

Details

  • DateGranularity is set to Automatic by default.
  • Granularity specifications may be any of the following:
  • "Eternity"an infinite period in the past or future
    "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
  • Constructors of DateObject expressions, such as FromDateString or FromAbsoluteTime, have a DateGranularity option.

Examples

open allclose all

Basic Examples  (2)

By default, DateObject generates dates with calendar granularity determined by the input:

Use DateGranularity"Instant" to generate a date with "Instant" granularity:

By default, RandomDate dates are generated with "Instant" granularity:

Use DateGranularity"Day" to generate a pseudorandom day:

Generate dates with calendar granularity "Month":

Scope  (2)

Available granularity specifications depend on the calendar associated with the date:

DateGranularity specifies the output granularity, regardless of the input granularity for the given dates:

Wolfram Research (2022), DateGranularity, Wolfram Language function, https://reference.wolfram.com/language/ref/DateGranularity.html (updated 2023).

Text

Wolfram Research (2022), DateGranularity, Wolfram Language function, https://reference.wolfram.com/language/ref/DateGranularity.html (updated 2023).

CMS

Wolfram Language. 2022. "DateGranularity." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2023. https://reference.wolfram.com/language/ref/DateGranularity.html.

APA

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

BibTeX

@misc{reference.wolfram_2023_dategranularity, author="Wolfram Research", title="{DateGranularity}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/DateGranularity.html}", note=[Accessed: 28-March-2024 ]}

BibLaTeX

@online{reference.wolfram_2023_dategranularity, organization={Wolfram Research}, title={DateGranularity}, year={2023}, url={https://reference.wolfram.com/language/ref/DateGranularity.html}, note=[Accessed: 28-March-2024 ]}