MATLAB Answers

how to combine date and time in single column

1 view (last 30 days)
MONICA RAWAT
MONICA RAWAT on 22 May 2020
Commented: MONICA RAWAT on 22 May 2020
suppose i have one table of date and another table of time as given below
date time
2013-11-23 23:32:29
2013-12-24 22:29:38
then i want my output to be given below in a single table
datetime
2013-11-23 23:32:29
2013-12-24 22:29:38

  2 Comments

MONICA RAWAT
MONICA RAWAT on 22 May 2020
both of these function is not working

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 22 May 2020
In what data type is your data stored?
If it's stored as char vectors then you can use the functions KSSV mentioned in the comment.
C = table();
C.date = ['2013-11-23'; '2013-12-24'];
C.time = ['23:32:29'; '22:29:38'];
C.dateAndTime = strcat(C.date, {' '}, C.time)
If they are a datetime and a duration just add them together.
C = table();
C.date = datetime({'2013-11-23'; '2013-12-24'});
C.time = duration({'23:32:29'; '22:29:38'});
C.dateAndTime = C.date + C.time

  1 Comment

MONICA RAWAT
MONICA RAWAT on 22 May 2020
data is stored in date an time format

Sign in to comment.