datetime_part()
This article describes datetime_part().
Extracts the requested date part as an integer value.
Syntax
datetime_part(
part,
datetime)
Parameters
Name | Type | Required | Description |
---|---|---|---|
part | string | ✔️ | Measurement of time to extract from date. See possible values. |
date | datetime | ✔️ | The full date from which to extract part. |
Possible values of part
- Year
- Quarter
- Month
- week_of_year
- Day
- DayOfYear
- Hour
- Minute
- Second
- Millisecond
- Microsecond
- Nanosecond
Returns
An integer representing the extracted part.
Example
let dt = datetime(2017-10-30 01:02:03.7654321);
print
year = datetime_part("year", dt),
quarter = datetime_part("quarter", dt),
month = datetime_part("month", dt),
weekOfYear = datetime_part("week_of_year", dt),
day = datetime_part("day", dt),
dayOfYear = datetime_part("dayOfYear", dt),
hour = datetime_part("hour", dt),
minute = datetime_part("minute", dt),
second = datetime_part("second", dt),
millisecond = datetime_part("millisecond", dt),
microsecond = datetime_part("microsecond", dt),
nanosecond = datetime_part("nanosecond", dt)
Output
year | quarter | month | weekOfYear | day | dayOfYear | hour | minute | second | millisecond | microsecond | nanosecond |
---|---|---|---|---|---|---|---|---|---|---|---|
2017 | 4 | 10 | 44 | 30 | 303 | 1 | 2 | 3 | 765 | 765432 | 765432100 |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.