trouble using datetime format in textscan
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Erik
el 20 de Jul. de 2021
Comentada: Erik
el 20 de Jul. de 2021
this datetime format works
datetime('2021-05-01 06:10:00','inputFormat','yyyy-MM-dd HH:mm:ss')
so why won't
>> textscan('2021-05-01 06:10:00','%{yyyy-MM-dd HH:mm:ss}D')
Error using textscan
Unable to read the DATETIME data with the format 'yyyy-MM-dd HH:mm:ss'. If the data is not a time, use %q to get text data.
Thanks.
0 comentarios
Respuesta aceptada
Cris LaPierre
el 20 de Jul. de 2021
The problem is because textscan uses white space as the default delimiter. Specify your delimiter or remove the space between date and time.
d1 = textscan('2021-05-01 06:10:00','%{yyyy-MM-dd hh:mm:ss}D','Delimiter','\t')
d2 = textscan('2021-05-0106:10:00','%{yyyy-MM-ddhh:mm:ss}D');
d2{1}.Format = 'yyyy-MM-dd hh:mm:ss'
Más respuestas (1)
Simon Chan
el 20 de Jul. de 2021
Detail explanation here: How do I use 'textscan' to correctly read a formatted date?
0 comentarios
Ver también
Categorías
Más información sobre Text Data Preparation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!