First you need to convert your string ('mm-dd-yy') to a date (yyyy-MM-dd). Then you can extract the year with year() function.
All in one: year(make_date(20||substr("obvserved_on",7,2),substr("obvserved_on",1,2),substr("obvserved_on",4,2)))
Note that you need to add 20 (or 19 or whatever) in front of your year (the 20||
part) since it is formatted with only two numbers instead of four.
Edit: as I can see in your Screenshot, your Datestring is not formatted as 'mm-dd-yy'
, but actually 'M/d/yyyy'
. You can use regular expressions or arrays in that case. Like this: year(make_date(array_get( string_to_array( "observed_on",'/'),2),array_get( string_to_array( "observed_on",'/'),0),array_get( string_to_array( "observed_on",'/'),1)))
You can create a new field by opening your attribute table and executing field calculator. Enter your expression there. See:
