Date Transformations with the Functions Node
The most important ⚠️ first step when dealing with date and time data is to understand the data type you're dealing with, in order to find the correct function.
This article will run through the different date and time data types and the most common functions you can use to work with them in Y42. All functions are available in the Functions Node.
The functions are grouped by:
- Functions to manipulate the format of date and time data (e.g. turn a timestamp into a date, extract the ISO week of a date)
- Functions to perform calculations with date and time data (e.g. calculate the difference between two dates)
- Functions to turn text data into date and time data (e.g. turn a text column into a date column)
Different types of date and time data
Data Type | Details | Y42 Icon |
---|---|---|
DATE |
|
|
DATETIME |
|
|
TIMESTAMP |
|
Functions to manipulate the format of date and time data
Function | Details |
---|---|
CONVERT_TO_DATE |
|
Function: |
|
CONVERT_TO_DATETIME |
|
Function: |
|
CONVERT_TO_TIMESTAMP |
|
Function: |
|
FORMAT_DATE |
|
Function: |
|
FORMAT_DATETIME |
|
Function: |
|
FORMAT_TIMESTAMP |
|
Function: |
|
LAST_DAY |
|
Function: |
|
DATE_TRUNC |
*Allowed values: DAY, WEEK, ISOWEEK, MONTH, QUARTER, YEAR, ISOYEAR |
Function: |
|
EXTRACT |
*Allowed values: MICROSECOND, MILLISECOND, SECOND, MINUTE, HOUR, DAYOFWEEK, DAY, DAYOFYEAR, WEEK, ISOWEEK, MONTH, QUARTER, YEAR, ISOYEAR |
Function: |
Functions to perform calculations with date and time data
Function | Details |
---|---|
DATE_ADD |
*Allowed values: DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
DATETIME_ADD |
*Allowed values: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
TIMESTAMP_ADD |
* Allowed values: MILLISECOND, MICROSECOND, SECOND, MINUTE, HOUR, DAY |
Function: |
|
DATE_SUB |
*Allowed values: DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
DATETIME_SUB |
*Allowed values: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
TIMESTAMP_SUB |
* Allowed values: MILLISECOND, MICROSECOND, SECOND, MINUTE, HOUR, DAY |
Function: |
|
DATE_DIFF |
*Allowed values: DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
DATETIME_DIFF |
*Allowed values: SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR |
Function: |
|
TIMESTAMP_DIFF |
* Allowed values: MILLISECOND, MICROSECOND, SECOND, MINUTE, HOUR, DAY |
Function: |
Functions to turn text data into date and time data
Function | Details |
---|---|
CAST_DATETIME |
|
Function: |
|
CAST_TIMESTAMP |
|
Function: |
|
PARSE_DATE |
|
Function: |
|
PARSE_DATETIME |
|
Function |
|
PARSE_TIMESTAMP |
|
Function: |