How to merge datetime and duration in two different columns?
4 ビュー (過去 30 日間)
古いコメントを表示
I have two columns with dates in first column and duration in second column. It is 999x4 timetable. Also the date is in format '13/02/0020' and not in '13/02/2020'. I have used following code to convert the original date in form of '13.02.2020'(cell array) to date time object
d=NewP{:,'Date'}
d1=datetime(d,"Locale","de_DE");
d1.Format='dd/MM/yyyy'
NewP.Date=d1

I want to plot a line graph between meltcushion and time for two different dates i.e 13/02 and 28/02, the graph is coming in the following form.
The data was taken at two different dates and both were taken from '9.30 am to 2.30 pm'.

My aim is to plot the graph at two different dates together. My desired output for column as following example
dt=datetime('today')
dnt=dt+NewP{1,"Time"}
dnt =
15-Mar-2020 09:32:57
But when I use the above example to merge the both columns

0 件のコメント
採用された回答
Steven Lord
2020 年 3 月 15 日
You told MATLAB you wanted to use the format 'dd/MM/yyyy' to display d1. Adding a duration to a datetime doesn't change the Format. But just because the duration data isn't displayed doesn't mean it was discarded.
% Make a datetime
dt = datetime('today', 'Format', 'dd/MM/yyyy')
% Add time data without affecting the Format
dt = dt + hours(0:23).'
% Show that there is actually a difference between elements in dt
% even though that difference is not visible due to the Format
dt(17)-dt(1)
% Change the Format to show the time data
dt.Format = 'dd/MM/yyyy HH:mm'
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!