How to convert a char into datetime variable?

8 vues (au cours des 30 derniers jours)
Marianna Pizzo
Marianna Pizzo le 21 Mar 2019
Commenté : Marianna Pizzo le 21 Mar 2019
Hello, how can I convert a char such as '11:04:55' to datetime variable?
Thank you very much.

Réponse acceptée

Guillaume
Guillaume le 21 Mar 2019
datetime('11:04:55')
Note that it will use the current date for the date part (since a datetime is always date + time as the name indicates). If you do not want the date to display (it will still be stored and can be accessed):
datetime('11:04:55', 'Format', 'HH:mm:ss')
You may want to use a duration type instead of datetime.
duation('11:04:55')
Just as easy.

Plus de réponses (0)

Catégories

En savoir plus sur Data Type Conversion dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by