フィルターのクリア

convert date time to number ?

3 ビュー (過去 30 日間)
MUKESH KUMAR
MUKESH KUMAR 2018 年 7 月 4 日
コメント済み: Aarti Dwivedi 2018 年 7 月 6 日
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 件のコメント
Walter Roberson
Walter Roberson 2018 年 7 月 4 日
Which number format is it?
Does the spreadsheet have the values stored as text string or as excel date format?
Stephen23
Stephen23 2018 年 7 月 4 日
編集済み: Stephen23 2018 年 7 月 4 日
Using datetime, datenum, or datevec, depending on your need. What have you tried so far?

サインインしてコメントする。

採用された回答

Aarti Dwivedi
Aarti Dwivedi 2018 年 7 月 4 日
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 件のコメント
Peter Perkins
Peter Perkins 2018 年 7 月 5 日
Unless you specifically need a datenum, this is almost certainly not the best choice. As Walter says, what number format do you need?
And in any case, in recent versions of MATLAB, you can read dates from Excel directly as datetimes, and it's likely that you do not need to convert them to a "number".
Aarti Dwivedi
Aarti Dwivedi 2018 年 7 月 6 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by