datetime without leading zero
5 次查看(过去 30 天)
显示 更早的评论
datetime('212704','InputFormat','Hmmss')
gives an error.
datetime('21:27:04','InputFormat','H:mm:ss')
does not.
This is a problem when importing time noted as hours without leading zero as in the first format using textscan. Using:
datetime('92704','InputFormat','HHmmss')
gives an error due to the lack of the leading zero. Any workaround for this?
0 个评论
回答(2 个)
the cyclist
2017-11-25
编辑:the cyclist
2017-11-25
Can you sneak a formatting step between the import and the date function?
sprintf('%06.0f',92704)
ans =
'092704'
and
sprintf('%06.0f',212704)
ans =
'212704'
and then use the 2-digit hour format?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!