MATLAB: Converting dates in textfile

datenum

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.

Best Answer

>> datetime(floor(A),1,1) + years(mod(A,1))
ans =
12Ă—1 datetime array
01-Jan-1880 00:00:00
31-Jan-1880 11:04:09
01-Mar-1880 20:23:08
01-Apr-1880 07:27:18
01-May-1880 18:31:27
01-Jun-1880 03:50:26
01-Jul-1880 14:54:36
01-Aug-1880 01:58:45
31-Aug-1880 11:17:44
30-Sep-1880 22:21:54
31-Oct-1880 09:26:03
30-Nov-1880 18:45:02