converting dates in textfile
Show older comments
Hello,
I am having problems trying to covert the dates from the first column on a textfile, called A
1880
1880.08340000000
1880.16660000000
1880.25000000000
1880.33340000000
1880.41660000000
1880.50000000000
1880.58340000000
1880.66660000000
1880.75000000000
1880.83340000000
1880.91660000000
Date = datenum(A{:,1});
Date = datetime(Date,'ConvertFrom','datenum');
The output gives:
'22-Feb-0005 00:00:00'
'22-Feb-0005 02:00:05'
'22-Feb-0005 03:59:54'
'22-Feb-0005 06:00:00'
'22-Feb-0005 08:00:05'
'22-Feb-0005 09:59:54'
'22-Feb-0005 12:00:00'
'22-Feb-0005 14:00:05'
'22-Feb-0005 15:59:54'
'22-Feb-0005 18:00:00'
This is obviously incorrect.
The dates in the raw textfile look like this:

Maybe I need to round the column to X number of decimal places BEFORE using the datenum function?
If so, how should I do this?
Thank you.
Accepted Answer
More Answers (0)
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!