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 CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by