format_datetime
This page explains how to use the format_datetime function in APL.
The format_datetime function formats a datetime value as a string according to a format pattern.
Usage
Syntax
APL
Parameters
| Parameter | Type | Description |
|---|---|---|
date | datetime | The datetime value to format. |
format | string | A non-empty string literal specifying the output format. Dynamic expressions or empty strings return an error. |
Supported format specifiers
Other characters in format are copied as-is. Month and day names are not supported.
| Specifier | Description |
|---|---|
y, yy, yyyy | Year (2-digit or 4-digit). |
M, MM | Month number (1–12 or 01–12). |
d, dd | Day of month (1–31 or 01–31). |
H, HH | 24-hour clock (0–23 or 00–23). |
h, hh | 12-hour clock (1–12 or 01–12). |
m, mm | Minutes (0–59 or 00–59). |
s, ss | Seconds (0–59 or 00–59). |
tt | AM/PM designator. |
f–fffffff | Fractional seconds (1 to 7 digits, including trailing zeros). |
F–FFFFFFF | Fractional seconds (1 to 7 digits, trailing zeros omitted). |
Returns
Returns a formatted string representation of date.
Examples
Query
APL
Output
| fmt1 | fmt2 | fmt3 |
|---|---|---|
17-01-29 [09:00:05 AM] | 2017-1-29 9:00:05.000 | 29/01/2017 09:00:05. |
List of related functions
- datetime_part: Extracts an integer component from a datetime value.
- datetime_add: Adds a period to a datetime value.
- datetime_diff: Calculates the difference between two datetime values.