convert date and time in seconds

24 visualizaciones (últimos 30 días)
Nivodi
Nivodi el 4 de Sept. de 2018
Comentada: jonas el 5 de Sept. de 2018
Hello everyone, I have a table with several variables. Among others, I have 2 columns with date and time. These 2 columns are cells with strings ('iscellstr'=1 and 'ischar'=0). How can I convert them in seconds? thank you very much!
  7 comentarios
jonas
jonas el 4 de Sept. de 2018
Not sure what you are doing, but that is not the correct syntax. I wrote some lines of code in the answer section to give you an idea of what I meant.
Nivodi
Nivodi el 4 de Sept. de 2018
I wrote that before I saw the answer that you wrote below. I am working on it now.

Iniciar sesión para comentar.

Respuesta aceptada

jonas
jonas el 4 de Sept. de 2018
Editada: jonas el 4 de Sept. de 2018
Here's a solution with datetime
data=load('matlab.mat')
T=data.T1_B6_09032017;
TimeOfDay=duration(T.time)
Date=datetime(T.date,'inputformat','dd.MM.yyyy')
t=Date+TimeOfDay;
If you really want the output in seconds, here is how you calculate the duration from the first measurement:
ts=seconds(t-t(1));
I suggest you then put the data in a timetable
TT=timetable(t,T);
TT=splitvars(TT);
  8 comentarios
Nivodi
Nivodi el 5 de Sept. de 2018
Thank you Jonas for your time and help!
jonas
jonas el 5 de Sept. de 2018
My pleasure! Don't forget to accept if the answer was helpful!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by