hour
Returns the hours in a given date string, s.
Syntax
R = hour(s)
R = hour(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. If in this format, hour returns 0.
- fmt (optional)
- Gives the given format that s is in. Valid formats that can return
a valid hour value are:
- 'dd-mmm-yyyy HH:MM:SS'
- 'HH:MM:SS'
- 'HH:MM:SS PM'
- 'HH:MM'
- 'HH:MM PM'
- 'mmm.dd,yyyy HH:MM:SS'
- 'yyyymmddTHHMMSS'
- 'yyyy-mm-dd HH:MM:SS'
Outputs
- R
- Hour in the given date string s. 0 is returned for most formats, fmt, which don't specify the hour.
Examples:
Return the hour from a string in a specific date format:
R = hour('Apr.04,2019 10:11:12', 'mmm.dd,yyyy HH:MM:SS')
R = 10