Derives the four-digit year value from a Datetime value. Source value can be a a reference to a column containing Datetime values or a literal.
NOTE: If the source Datetime value does not include a valid input for this function, a missing value is returned.
Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.
Basic Usage
year(MyDate)
Output: Returns the four-digit year values from the MyDate
column.
Syntax and Arguments
year(datetime_col)
Argument | Required? | Data Type | Description |
---|---|---|---|
datetime_col | Y | datetime | Name of column whose year values are to be computed |
For more information on syntax standards, see Language Documentation Syntax Notes.
datetime_col
Name of the column whose year value is to be computed.
- 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 | Datetime | myDate |
Tip: For additional examples, see Common Tasks.
Examples
Example - Date element functions
YEAR
- Returns the four-digit year value from a Datetime value. See YEAR Function.MONTH
- Returns the two-digit month value from a Datetime value. See MONTH Function.MONTHNAME
- Returns the full month name value from a Datetime value. See MONTHNAME Function.WEEKDAYNAME
- Returns the weekday name value from a Datetime value. See WEEKDAYNAME Function.DAY
- Returns the day of the month as a numeric value from a Datetime value. See DAY Function.HOUR
- Returns the hour value on a 24-hour scale from a Datetime value. See HOUR Function.MINUTE
- Returns the minutes value from a Datetime value. See MINUTE Function.SECOND
- Returns the seconds value from a Datetime value. See SECOND Function.
Source:
date |
---|
2/8/16 15:41 |
12/30/15 0:00 |
4/26/15 7:07 |
Transformation:
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | YEAR (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | MONTH (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | MONTHNAME (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | WEEKDAYNAME (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | DAY (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | HOUR (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | MINUTE (date) |
Transformation Name | New formula |
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | SECOND (date) |
Results:
NOTE: If the source Datetime value does not contain a valid input for one of these functions, no value is returned. See the second_date
column below.
date | year_date | month_date | monthname_date | weekdayname_date | day_date | hour_date | minute_date | second_date |
---|---|---|---|---|---|---|---|---|
2/8/16 15:41 | 2016 | 2 | February | Monday | 8 | 15 | 41 | |
12/30/15 0:00 | 2015 | 12 | December | Wednesday | 30 | 0 | 0 | |
4/26/15 7:07 | 2015 | 4 | April | Sunday | 26 | 7 | 7 |
This page has no comments.