Date & Time

Input Date & Time

Instead of numerical data, dates and times can also be passed to ChartData(). For example:

ChartData(1/1/2023 3/17/2023 3/18/2023 10/22/2023)

ChartData(1:00 8:32 14:01:38 23:22:11)

Combined dates and times (so-called timestamps) are also permitted. The date and time are joined together by an ampersand (&). For example:

ChartData(2023-01-01&11:22 2023-03-22&18:33:00)

Periods (.), slashes (/) and hyphens (-) can be used to separate the date components entered. Colons (:) and apostrophes (') can be used to enter the times. Typographical apostrophes (‘’) are not allowed. For example:

ChartData(1.1.2023 4/13/2023 2023-05-22)

ChartData(0:22 11:22:33 3'13 14'05'22)

The 1st argument dateOrder of the function DateTimeOptions() can be used to predefine the order of day, month and year when entering the date. The following three orders are permitted:

Date orderConstantValueExample
year, month, dayymd12023-08-04
month, day, yearmdy2 (default)8/4/2023
day, month, yeardmy34.8.2023

To rule out ambiguities when entering the date, e.g. 8/4/23 (European: April 8, 2023 or American: August 4, 2023), the following rules should be followed:

  • Years should always include the century, e.g. 2023 and not 23. If the century is left out, then the two-digit year will automatically be turned into a four-digit year by xmCHART. The conversion can be carried out when the four-digit year, starting with the current year, lies either within the previous 70 years or within the next 30 years. For example, if the current year is 2023, then the years 00, 01, 02 to 53 will be turned into the years 2000, 2001, 2002 to 2052 and the years 54 to 99 into 1954 to 1999. If the current year is 2024, then the years 00, 01, 02 to 54 will be turned into the years 2000, 2001, 2002 to 2054 and the years 55 to 99 into 1955 to 1999.
  • If the date is entered in the order of day-month-year or month-day-year, then it is always advisable to specifically predefine the date order by using the function DateTimeOptions(). When using the order of year-month-day (recommended), it is not absolutely necessary as this order is clear — provided the year is entered with the century.

Examples:

ChartData(2023-02-01 2023-04-12) /* Year-month-day (Recommended) */

 

DateTimeOptions(dmy) /* European */

ChartData(1/2/2023 12/4/2023) /* Feb. 1, Apr. 12 */

 

DateTimeOptions(mdy) /* American */

ChartData(1/2/2023 12/4/2023) /* Jan. 2, Dec. 4 */

Output Date & Time

Format specifiers are to be placed between vertical bars | ... |. Leading and trailing texts can be attached as an option. The general structure is:

"[string] | specifiers | [string]"  ( Optional components in square brackets [ ... ] )

The following xmCHART functions support texts with date & time format specifiers:

For example:

AxisMajorTickLabelTexts(x;​"|M/D/YY|")

AxisMinorTickLabelTexts(x;​"|hh|h")

AxisMajorTickLabelTexts(x;​"Week: |WY|")

Specifier Constant Notes
Year specifiers YY Year without century
  YYYY Year with 4 digits
     
Quarter specifier Q Quarter of year (1..4)
  Qx Quarter with English ordinal suffix, not localized
  QX Quarter with English ordinal suffix, not localized, uppercase
     
Month specifiers M Month of year (1..12)
  MM Month of year with leading 0 (01..12)
  Mo 1st letter of localized month name, uppercase
  Mon Abbr. month name, localized
  MON Abbr. month name, localized, uppercase
  Month Month name, localized
  MONTH Month name, localized, uppercase
     
Week specifiers W Weekday index (Sunday=1, Monday=2, ...)
  WY Week of year (1..53). The week starting day is defined by DateTimeOptions().
  WWY Week of year with leading 0 (01..53)
  WD1 1st letter of localized weekday name, uppercase
  Wd2 2-letter abbr. of localized weekday name
  WD2 2-letter abbr. of localized weekday name, uppercase
  Wd3 Abbr. weekday name, localized
  WD3 Abbr. weekday name, localized, uppercase
  Weekday Weekday name, localized
  WEEKDAY Weekday name, localized, uppercase
     
Day specifiers D Day of month (1..31)
  DD Day of month with leading 0 (01..31)
  DY Day of year (1..366)
  DDY Day of year with leading 0 (001..366)
  Dx Day with English ordinal suffix, not localized
  DX Day with English ordinal suffix, not localized, uppercase
     
Time specifiers h Hour in 24-hour format (0..23)
  hh Hour in 24-hour format with leading 0 (00..23)
  h12 Hour in 12-hour format (1..12)
  hh12 Hour in 12-hour format with leading 0 (01..12)
  m Minute (0..59)
  mm Minute with leading 0 (00..59)
  s Second (0..59)
  ss Second with leading 0 (00..59)
  ampm am or pm (in combination with h12 or hh12)
  AMPM AM or PM (in combination with h12 or hh12)
Example Format Result
7/31/2023 "|M/D/YY|" 7/31/23
  "|D.M.YYYY|" 31.7.2023
  "|YYYY-MM-DD|" 2023-07-31
  "|YYYYMMDD|" 20230731
  "|D Month YYYY|" 31 July 2023
  "|MON D, YYYY|" JUL 31, 2023
  "|Wd3, MONTH D|" Mon, JULY 31
8/20/2023 "Q|Q/YYYY|" Q3/2023
  "Week: |WY/YYYY|" Week: 34/2023 /* Calendar week starts on Sunday. */
  "W|WY: Weekday|" W33: Sunday /* Calendar week starts on Monday. */
  "|M/D (#DY)|" 8/20 (#232)
1:58:04 "|h:mm:ss|" 1:58:04
  "|hh:mm|" 01:58
  "Time: |h:mm:ss|" Time: 1:58:04
9:15:00 "|h12:mm AMPM|" 9:15 AM
14:05:32 "|h12:mm ampm|" 2:05 pm
Scroll to Top