Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
NoSQL
Formats a datetime value based on the specified format string.
Syntax
DATETIMEFORMAT(<date_time>, <string_expr>)
Arguments
| Description | |
|---|---|
date_time |
The datetime value to format. |
string_expr |
The format string includes one or more of the supported format specifiers and other characters. |
Return types
Returns a string expression.
Examples
The following example shows different formatting options for datetime values.
SELECT VALUE {
"case1": DATETIMEFORMAT("2024-10-10 14:40:20", "yyyyMMdd"),
"case2": DATETIMEFORMAT("2024-10-10 14:40:20", "yyyy-MM-dd [HH:mm:ss]"),
"case3": DATETIMEFORMAT("2024-10-10 14:40:20", "To\\da\\y i\\s: yyyy-MM-ddTHH:mm:ss.fff"),
"case4": DATETIMEFORMAT("2024-10-10 14:40:20", "To\\da\\y i\\s: yyyy-MM-ddTHH:mm:ss.FFF")
}
[
{
"case1": "20241010",
"case2": "2024-10-10 [14:40:20]",
"case3": "Today is: 2024-10-10T14:40:20.000",
"case4": "Today is: 2024-10-10T14:40:20."
}
]
Remarks
- This function performs a full scan.