Contents:
- Source values can be Integer literals or column references to values that can be inferred as Integers.
- If any of the source values are invalid or out of range, a missing value is returned.
- This function must be nested within another function that accepts date values as arguments. See the example below.
Basic Usage
Integer literal values:
derive type:single value: DATEFORMAT(TIME(23,58,59),'HH mm ss')
Output: Generates a column of values containing the map:
23 58 59
Column reference values:
derive type:single value: DATEFORMAT(TIME(myHour, myMinute, mySecond), 'hh-mm-ss')
Output: Generates a column of values where:
hh
= values frommyHour
columnmm
= values frommyMinute
columnss
= values frommySecond
column
Syntax and Arguments
derive type:single value:DATEFORMAT(TIME(hour_integer_col,minute_integer_col,second_integer_col),'time_format_string')
Argument | Required? | Data Type | Description |
---|---|---|---|
hour_integer_col | Y | integer | Name of column or Integer literal representing the hour value to apply to the function |
minute_integer_col | Y | integer | Name of column or Integer literal representing the minute value to apply to the function |
second_integer_col | Y | integer | Name of column or Integer literal representing the second value to apply to the function |
time_format_string | Y | string | String literal identifying the time format to apply to the value |
For more information on syntax standards, see Language Documentation Syntax Notes.
hour_integer_col
Integer literal or name of the column containing integer values for the hour. Values must integers between 0 and 23, inclusive.
- Missing values for this function in the source data result in missing values in the output.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | Integer (literal or column reference) | 15 |
minute_integer_col
Integer literal or name of the column containing integer values for the minutes. Values must integers between 0 and 59, inclusive.
- Missing values for this function in the source data result in missing values in the output.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | Integer (literal or column reference) | 23 |
second_integer_col
Integer literal or name of the column containing integer values for the second. Values must integers between 0 and 59, inclusive.
- Missing values for this function in the source data result in missing values in the output.
- Multiple columns and wildcards are not supported.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | Integer (literal or column reference) | 45 |
time_format_string
For more information on supported time formatting strings, see Supported Data Types.
For more information, see DATEFORMAT Function.
Tip: For additional examples, see Common Tasks.
Examples
Example - date and time functions
DATE
and TIME
functions operate. Both functions require that their outputs be formatted properly using the DATEFORMAT
function.DATE
- Generates valid Datetime values from three integer inputs: year, month, and day. See DATE Function.TIME
- Generates valid Datetime values from three integer inputs: hour, minute, and second. See TIME Function.DATETIME
- Generates valid Datetime values from six integer inputs: year, month, day, hour, minute, and second. See DATETIME Function.DATEFORMAT
- Formats valid Datetime values according to the provided formatting string. See DATEFORMAT Function.
Source:
year | month | day | hour | minute | second |
---|---|---|---|---|---|
2016 | 10 | 11 | 2 | 3 | 0 |
2015 | 11 | 20 | 15 | 22 | 30 |
2014 | 12 | 25 | 18 | 30 | 45 |
Transform:
derive type:single value: DATEFORMAT(DATE (year, month, day),'yyyy-MM-dd') as:'fctn_date'
derive type:single value: DATEFORMAT(TIME (hour, minute, second),'HH-mm-ss') as:'fctn_time'
derive type:single value: DATEFORMAT(DATETIME (year, month, day, hour, minute, second),'yyyy-MM-dd-HH:mm:ss') as:'fctn_datetime'
Results:
NOTE: All inputs must be inferred as Integer type and must be valid values for the specified input. For example, month values must be integers between 1 and 12, inclusive.
year | month | day | hour | minute | second | fctn_date | fctn_time | fctn_datetime |
---|---|---|---|---|---|---|---|---|
2016 | 10 | 11 | 2 | 3 | 0 | 2016-10-11 | 02-03-00 | 2016-10-11-02:03:00 |
2015 | 11 | 20 | 15 | 22 | 30 | 2015-11-20 | 15-22-30 | 2015-11-20-15:22:30 |
2014 | 12 | 25 | 18 | 30 | 45 | 2014-12-25 | 18-30-45 | 2014-12-25-18:30:45 |
You can apply other date and time functions to the generated columns. For an example, see YEAR Function.
This page has no comments.