convert date time to number ?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
2018년 7월 4일
Which number format is it?
Does the spreadsheet have the values stored as text string or as excel date format?
채택된 답변
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
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
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 Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!