Converting datenum to days

26 ビュー (過去 30 日間)
Karthik Sharma
Karthik Sharma 2018 年 5 月 7 日
回答済み: Star Strider 2018 年 5 月 7 日
I'm doing some data interpretation and I want to convert the output that I'm getting to days. How exactly do I do this?

採用された回答

Star Strider
Star Strider 2018 年 5 月 7 日
The output of datenum are whole days to the left of the decimal separator (as the number of days from January 0, 0000), and fractions of a day to the right. You can get other details about the days using the appropriate datetime (link) functions.
Example
dn = now % Date Number
dt = datetime(dn, 'ConvertFrom','datenum') % Corresponding ‘datetime’ Object
daynr = day(dt) % Day Of The Month
dayyr = day(dt, 'dayofyear') % Day Of The Year
dn =
737187.560337454
dt =
07-May-2018 13:26:53
daynr =
7
dayyr =
127

その他の回答 (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