month
Returns the month of a given date string, s.
Syntax
[R, name] = month(s)
[R,...] = month(s, fmt)
Inputs
- s
- A string representing a date. By default, if no fmt is specified, s is expected to be in the format dd-mmm-yyyy.
- fmt
- An optional argument which gives the given format s is in. Valid formats that can return month are: 'dd-mmm-yyyy HH:MM:SS' 'dd-mmm-yyyy' 'mm/dd/yy' 'mmm' 'm' 'mm' 'mm/dd' 'mmmyy' 'dd/mm' 'dd/mm/yy' 'mmm.dd,yyyy HH:MM:SS' 'mmm.dd,yyyy' 'mm/dd/yyyy' 'dd/mm/yyyy' 'yy/mm/dd' 'yyyy/mm/dd' 'mmmyyyy' 'yyyy-mm-dd' 'yyyymmddTHHMMSS' 'yyyy-mm-dd HH:MM:SS'
Outputs
- R
- Month number from the given date s
- name
- Short description of the month name from the given date s
Examples:
R = month('10-Apr-2019')
R = 4
[R, name] = month('Apr.04,2019 10:11:12', 'mmm.dd,yyyy HH:MM:SS')
R = 4
name = Apr
Version History
2022.2