Reading time from the year numbers, day numer and hour number

2 ビュー (過去 30 日間)
Vijay Sagar
Vijay Sagar 2021 年 5 月 30 日
コメント済み: Star Strider 2021 年 5 月 31 日
Hi everyone! How to extract the time from the year number, day number and hour number and combine them into single date time. Example yyyy-mm-dd HH:MM:SS.
Here is one of the sample data:
yearnumber=2019.24917302
day_number=91.19733;
hour_number=4.73580;
  2 件のコメント
Jan
Jan 2021 年 5 月 30 日
編集済み: Jan 2021 年 5 月 30 日
What is the wanted output? Should we assume, that in 2019.24917302 the fractional part is the fraction of the complete year inlucding leap days? Does the farctional part of 91.19733 mean the second 0.19733 * 86400?
Vijay Sagar
Vijay Sagar 2021 年 5 月 31 日
Sir, the output is :
2019-05-02 04:44:00
Yes, It is ractional part is the fraction of the complete year inlucding leap days. I also don't know wheather it is a fractional part of 91.19733. The answer given by @Star Strideris correct.

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

採用された回答

Star Strider
Star Strider 2021 年 5 月 30 日
I cannot find a way using the MATLAB date and time functions to convert these automatically.
Try this —
year_number=2019.24917302;
day_number=91.19733;
hour_number=4.73580;
Convert = @(year_number,hour_number,day_number) datetime([fix(year_number) fix(rem(year_number,1)*12) fix(day_number) fix(hour_number) fix(rem(hour_number,1)*60) 0]);
Out = Convert(year_number,hour_number,day_number)
Out = datetime
02-May-2019 04:44:00
.
  2 件のコメント
Vijay Sagar
Vijay Sagar 2021 年 5 月 31 日
Sir, Thank you so much. It is helpful.
Star Strider
Star Strider 2021 年 5 月 31 日
As always, my pleasure!

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

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