convert date time to number ?

2 vues (au cours des 30 derniers jours)
MUKESH KUMAR
MUKESH KUMAR le 4 Juil 2018
Commenté : Aarti Dwivedi le 6 Juil 2018
I had excel sheet having date format dd/mm/yyyy hh:mm:ss , So now I want to convert each value into number format. How can I do this?
  2 commentaires
Stephen23
Stephen23 le 4 Juil 2018
Modifié(e) : Stephen23 le 4 Juil 2018
Using datetime, datenum, or datevec, depending on your need. What have you tried so far?

Connectez-vous pour commenter.

Réponse acceptée

Aarti Dwivedi
Aarti Dwivedi le 4 Juil 2018
https://www.mathworks.com/help/matlab/ref/datenum.html Assuming that you have already read the values from the Excel sheet in different variables, the number you are looking for is "numd", it can be obtained using:
date_arr = datetime(yyyy,mm,dd,hh,mm,ss)
numd = datenum(date_arr)
  2 commentaires
Aarti Dwivedi
Aarti Dwivedi le 6 Juil 2018
The OP wanted a "number", that's why I provided it. Although I agree with you that it is not the best choice, I put it with datetime as well as datenum so that it would be clear to a MATLAB novice and the OP the difference between the two.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by