Clear Filters
Clear Filters

convert excel date to datetime

4 views (last 30 days)
hafiz hashim
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');

Accepted Answer

Star Strider
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
hafiz hashim
hafiz hashim on 25 Oct 2019
Thank you so much for your help
Star Strider
Star Strider on 25 Oct 2019
As always, my pleasure!

Sign in to comment.

More Answers (0)

Categories

Find more on Dates and Time in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!