hour

Hour of date or time

Syntax

Hour = hour(Date)
Hour = hour(___,F)

Description

Hour = hour(Date) returns the hour of the day given a serial date number or a character vector representing a date and time.

Hour = hour(___,F) returns the hour of one or more character vectors representing a date and time using a format defined by the optional input F. Date can be an array of character vectors, where each row corresponds to one character vector, or a one-dimensional cell array of character vectors. All the character vectors in Date must have the same format F. F must designate a supported date format symbol. For more information on supported date formats, see datestr.

Examples

collapse all

Find the hour of the day for Date using a serial date number.

Hour = hour(730473.5584278936)
Hour = 13

Find the hour of the day for Date using a character vector representing a date and time.

Hour = hour('19-dec-1999, 13:24:08.17')
Hour = 13

Input Arguments

collapse all

Date to determine hour, specified as a serial date number or a character vector representing a date and time.

Date can be an array of character vectors representing a date and time, where each row corresponds to one character vector, or a one-dimensional cell array of character vectors. All of the character vectors in Date must have the same format F. F must designate a supported date format symbol. For more information on supported date formats, see datestr

Data Types: single | double | char | cell

Date format symbol, specified as a character vector to designate the date format symbol for input argument Date. For more information on supported character vector formats, see datestr. Note, formats with 'Q' are not accepted.

Data Types: char

Output Arguments

collapse all

Hour of the day, returned as a nonnegative number.

Introduced before R2006a