Date Conversion Not Working Again

2 ビュー (過去 30 日間)
Chameleon17
Chameleon17 2017 年 11 月 14 日
コメント済み: Chameleon17 2017 年 11 月 14 日
Hi, I'm sorry for posting a similar problem again - I keep encountering it and I'm not sure what i'm doing wrong. I simply want to upload a series of dates into MatLab but every time it goes through datnum to datestr the dates that come out are completely different to those I put in. I thought the problem last time might have been using excel to upload the data so now I'm only using text files. I have attached the bit of code and my input file - the first three dates I get back in the date string are - 04-Apr-2017, 06-Jul-2018, 06-Oct-2018. Any help or advice would be very much appreciated.
% Load OB Data
OB20172 = readtable('OB20176.txt');
% Create GS Time
datetime.setDefaultFormats('default','dd-MM-yyyy');
t1 = datetime(2017,04,1,0,0,0);
t2 = datetime(2017,10,31,8,0,0);
GS2017 = t1:t2;
%Convert OB Date
OBDates = OB20172;
OB2017 = table2array(OBDates);
OBDateNumbers = datenum(OB2017);
DateString = datestr(OBDateNumbers);
  1 件のコメント
Chameleon17
Chameleon17 2017 年 11 月 14 日
I figured it out - this can be deleted if this repetitive.
OB20172 = readtable('OB20176.txt','Format','%{dd/MM/yyyy}D','DateLocale','en_UK');

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by