Date & Time
Input Date & Time
Instead of numerical data, dates and times can also be passed to ChartData(). For example:
Combined dates and times (so-called timestamps) are also permitted. The date and time are joined together by an ampersand (&). For example:
ChartData(2025-01-01&11:22 2025-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:
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 order | Constant | Value | Example |
---|---|---|---|
year, month, day | ymd | 1 | 2025-08-04 |
month, day, year | mdy | 2 (default) | 8/4/2025 |
day, month, year | dmy | 3 | 4.8.2025 |
To rule out ambiguities when entering the date, e.g. 8/4/25 (European: April 8, 2025 or American: August 4, 2025), the following rules should be followed:
- Years should always include the century, e.g. 2025 and not 25. 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 2025, then the years 00, 01, 02 to 55 will be turned into the years 2000, 2001, 2002 to 2055 and the years 56 to 99 into 1956 to 1999. If the current year is 2026, then the years 00, 01, 02 to 56 will be turned into the years 2000, 2001, 2002 to 2056 and the years 57 to 99 into 1957 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(2025-02-01 2025-04-12) /* Year-month-day (Recommended) */
DateTimeOptions(dmy) /* European */
ChartData(1/2/2025 12/4/2025) /* Feb. 1, Apr. 12 */
DateTimeOptions(mdy) /* American */
ChartData(1/2/2025 12/4/2025) /* 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/2025 | "|M/D/YY|" | 7/31/25 |
"|D.M.YYYY|" | 31.7.2025 | |
"|YYYY-MM-DD|" | 2025-07-31 | |
"|YYYYMMDD|" | 20250731 | |
"|D Month YYYY|" | 31 July 2025 | |
"|MON D, YYYY|" | JUL 31, 2025 | |
"|Wd3, MONTH D|" | Mon, JULY 31 | |
8/17/2025 | "Q|Q/YYYY|" | Q3/2025 |
"Week: |WY/YYYY|" | Week: 34/2025 /* Calendar week starts on Sunday. */ | |
"W|WY: Weekday|" | W33: Sunday /* Calendar week starts on Monday. */ | |
"|M/D (#DY)|" | 8/17 (#229) | |
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 |