Hello!
I have a data item called [Date] that returns a date (full string date e.g. 01/03/2021). I want to return 2021. I know of the expression month() but how can I get the year from this in a data item expression? Should I just duplicate the data item and display it as YYYY by changing the data format?
Quote from: t0mato on 08 Sep 2021 12:23:56 PM
Hello!
I have a data item called [Date] that returns a date (full string date e.g. 01/03/2021). I want to return 2021. I know of the expression month() but how can I get the year from this in a data item expression? Should I just duplicate the data item and display it as YYYY by changing the data format?
Hi,
If you need just the year value on its own, you can use the extract() function to get it, eg
extract(year, [Date])
This is useful if you need to use the year in a calculation or filter, or to group on the year in your report. If none of these apply, you could use formatting to hide the day and month parts, but be aware the item will still contain a full date on each row under the covers.
Cheers!
MF.
Quote from: MFGF on 08 Sep 2021 12:56:12 PM
Hi,
If you need just the year value on its own, you can use the extract() function to get it, eg
extract(year, [Date])
This is useful if you need to use the year in a calculation or filter, or to group on the year in your report. If none of these apply, you could use formatting to hide the day and month parts, but be aware the item will still contain a full date on each row under the covers.
Cheers!
MF.
This is exactly what I needed. I was using the RIGHT function instead but this appears to literally be built for working with dates. Thank you!