convert excel date to datetime
4 views (last 30 days)
Show older comments
hafiz hashim
on 25 Oct 2019
Commented: Star Strider
on 25 Oct 2019
how can i covert '20-Nov-18 12:00:00 PM GMT' by using datetime. i try by using fillowing command but it didnt work. can anyone please help me out
d = datetime(S.textdata, 'InputFormat', 'dd-MM-yy HH:mm, 'TimeZone', 'UTC');
thanks
d = datetime(S.textdata, 'InputFormat', 'dd-MM-yy HH:mm, 'TimeZone', 'UTC');
0 Comments
Accepted Answer
Star Strider
on 25 Oct 2019
The format has to match exactly.
Both of these work:
S.textdata = '20-Nov-18 12:00:00 PM GMT';
d1 = datetime(S.textdata(1:end-4), 'InputFormat', 'dd-MM-yy hh:mm:ss a', 'TimeZone', 'UTC')
d2 = datetime(S.textdata, 'InputFormat', 'dd-MM-yy hh:mm:ss a ''GMT''', 'TimeZone', 'UTC')
producing:
d1 =
datetime
20-Nov-2018 12:00:00
d2 =
datetime
20-Nov-2018 12:00:00
Experiment to get the result you want.
2 Comments
More Answers (0)
See Also
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!