Converting Date and Time to Number
27 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Justin Duval
am 11 Feb. 2015
Kommentiert: Star Strider
am 11 Feb. 2015
Hi guys,
I have read in a column of dates and times from an excel document using xlsread and now have a cell of dates in the form 'yyyy-mm-dd hh:mm:ss AM/PM'.
I would like to extract from this cell a vector with the time in the form hhmm. How might I go about doing this?
Thanks,
Justin
0 Kommentare
Akzeptierte Antwort
Star Strider
am 11 Feb. 2015
5 Kommentare
Star Strider
am 11 Feb. 2015
My pleasure!
dt = {'2014-02-10 10:15:27 PM'}; % Original Date
dn = datenum(dt, 'yyyy-mm-dd HH:MM:SS AM'); % Date Number
tv = datevec(dn); % Date Vector
hhmm = tv(:,4:5) % Get Hour & Minute Fields
produces:
hhmm =
22 15
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!