Reading string formatted Date and Time from CSV

5 visualizaciones (últimos 30 días)
Yuri Katz
Yuri Katz el 18 de Feb. de 2022
Respondida: Star Strider el 18 de Feb. de 2022
Hi
I have csv files with the following format of date and time:
"Saturday, 12 February 2022 22:00:12"
Obviously this just one of the columns in the file, with additional data in adjacent columns. How can this be read into usable date and time data?
Thanks

Respuesta aceptada

Star Strider
Star Strider el 18 de Feb. de 2022
Obviously this just one of the columns in the file, with additional data in adjacent columns. How can this be read into usable date and time data?
str = "Saturday, 12 February 2022 22:00:12";
dt = datetime(str, 'InputFormat',"eeee, d MMMM yyyy HH:mm:ss")
dt = datetime
12-Feb-2022 22:00:12
See the datetime documentation section on infmt ('InputFormat') for more examples and an extended discussion. See the Format section to understand how to set the display format for the array datetime produces.
Replace ‘str’ here with the column reference to your table.
.

Más respuestas (1)

KSSV
KSSV el 18 de Feb. de 2022
REad about readtable.

Categorías

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by