convert character date string to date vector
1 回表示 (過去 30 日間)
古いコメントを表示
Hello
I have a date character string in the following format "2014-07-03T04:00:00.000000Z" within a table structure. I wish to convert this to a format which I can plot on a graph axis using the plot function.
plot(x,y)
where x is the date and y is some time series of data.
How can i convert the current date format?
0 件のコメント
回答 (1 件)
YT
2019 年 2 月 4 日
編集済み: YT
2019 年 2 月 4 日
myString = '2014-07-03T04:00:00.000000Z';
myDateString = datetime(myString,'InputFormat','yyyy-MM-dd''T''HH:mm:ss.SSS''Z','TimeZone','UTC');
dateOnly = myDateString; %create copy for dates
timeOnly = myDateString; %create copy for times
dateOnly.Format = 'dd-MM-yyyy'; %dates / x
timeOnly.Format = 'HH:mm:ss.SSS'; %times / y
or use regular expressions
D = regexp(input,'(?<date>.*?)T(?<time>.*?)Z','names');
%D.date = '2014-07-03'
%D.time = '04:00:00.000000';
2 件のコメント
madhan ravi
2019 年 2 月 4 日
編集済み: madhan ravi
2019 年 2 月 4 日
input() is an in-built function so naming a variable as input is not a good idea.
参考
カテゴリ
Help Center および File Exchange で Time Series Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!