How can I build a formula to extract the year of a date field? I'm trying to do this with the field DateofBirth
of datatype date
.
For example if DateofBirth=1980-12-19 00:00:00
, I want the formula to evaluate to the year=1980
According to your question. try with this. This should work
RIGHT(LEFT(TEXT(DateofBirth),4),4)
TEXT
...you should just use MID
to get the correct substring.
If you have a Date
field, you can simply use the YEAR()
formula function
The reason why you want to use this over manually splitting up a date string (besides it being shorter) is because the display format of a date/datetime field depends on the locale of the user.
There are lots of locales, and not all of them have the year in the same place (first good examples I found were Azerbaijan and Belarus).