year function
The year function returns the year value of an attribute containing a date.
Parameters
year(date)
Parameter | Description |
---|---|
date | The date, week, month, quarter or datetime attribute type from which you want retrieve the month value. The date parameter is mandatory. |
Date type valid formats (if the values aren’t this format, the function will return an error).
2019/10/12;
12/10/2019;
2019-10-12;
12-10-2019;
2019/Oct/12;
12/Oct/2019;
2019-Oct-12;
12-Oct-2019.
Week type valid formats (if the values aren’t this format, the function will return an error).
2019/W41;
W41/2019;
2019-W41;
W41-2019.
Month type valid formats (if the values aren’t this format, the function will return an error).
1492/10;
10/1492;
1492-10;
10-1492;
1492/Oct;
1492-Oct;
Oct/1492;
Oct-1492.
Quarter type valid formats (if the values aren’t this format, the function will return an error).
2019/Q3;
Q3/2019;
2019-Q3;
Q3-2019.
Datetime type valid formats (if the values aren’t this format, the function will return an error).
2019/05/22 17:33:45
Example
The following example uses the Instagram_data dataset.
Description | Screenshot |
---|---|
In this example, imagine the Year attribute doesn’t exist, and we want to fill a new attribute with the year value of the Date Posted attribute. Add a new attribute, called newyear, and type the following formula:
and the attribute will be populated with the year of the datetime attribute Date Posted. You can double check the results by comparing the column with the existing Year one. |