datatable.time module provides functions for working with temporal columns (date32 and time64). You can extract individual components (year, month, day, etc.) from a date or timestamp column, compute derived values such as day-of-week, or construct new temporal columns from their components.
All
dt.time extractor functions accept FExpr[date32] or FExpr[time64] columns and return integer FExpr results. They operate lazily and must be used inside a DT[rows, cols] expression.Component extraction functions
Date components
| Function | Input types | Returns | Description |
|---|---|---|---|
dt.time.year(date) | date32, time64 | int32 | Year component. |
dt.time.month(date) | date32, time64 | int32 | Month component (1–12). |
dt.time.day(date) | date32, time64 | int32 | Day-of-month component (1–31). |
dt.time.day_of_week(date) | date32, time64 | int32 | Day of week (Monday = 1, Sunday = 7). |
Time components
| Function | Input types | Returns | Description |
|---|---|---|---|
dt.time.hour(ts) | time64 | int32 | Hour component (0–23). |
dt.time.minute(ts) | time64 | int32 | Minute component (0–59). |
dt.time.second(ts) | time64 | int32 | Second component (0–59). |
dt.time.nanosecond(ts) | time64 | int32 | Nanosecond component (0–999,999,999). |
Construction functions
dt.time.ymd(year, month, day)
Create a date32 column from integer year, month, and day component columns. Invalid calendar combinations (e.g., February 30) produce NA.
Parameters
Year values.
Month values (1–12). Values outside this range produce NA.
Day values (1 to the last day of the given month). Invalid day/month combinations produce NA.
FExpr[date32].
dt.time.ymdt(year, month, day, hour, minute, second, nanosecond=0, *, date=None)
Create a time64 column from component columns. Invalid date combinations produce NA; time components have no range checks (e.g., you can pass second=3600 instead of hour=1).
You can replace the year, month, day triple with a single date parameter of type date32.
Parameters
Year values.
Month values (1–12).
Day values (1 to the last day of the given month).
Hour values.
Minute values.
Second values.
Nanosecond values. Optional.
Alternative to the
year/month/day triple. Cannot be combined with those parameters.FExpr[time64].