year

year returns the year from a given date.
  • year(str) returns from the date string str the corresponding year assuming the date format is 'mm/dd/yyyy'
  • year(str,dateformat) uses the date format specified in the second parameter. Available formats:
    • 'yyyy/mm/dd'
    • 'yyyy-mm-dd'
    • 'mm/dd/yyyy'
    • 'mm-dd-yyyy'
    • 'dd/mm/yyyy'
    • 'dd-mm-yyyy'
    • 'dd/mmm/yyyy'

Examples

>> year('12/02/2015')

[ans:2015]

>> year({'2015,05,15'; '2014, 01, 24'}, 'yyyy,mm,dd')#

         2015
         2014

See also

datenum | datevec | month