change julian date to format time

9 ビュー (過去 30 日間)
nada
nada 2018 年 6 月 3 日
コメント済み: Star Strider 2018 年 6 月 3 日
Hi
How i can convert Julian date to formatOut = 'mmmm/dd/yyyy hh:mm:ss';
(719801.916666667) (719801.958333333) (719802)
  2 件のコメント
Paolo
Paolo 2018 年 6 月 3 日
Are you sure the values you shared are in Julian date format and not datenum?
a = 719801.916666667;
The command:
datetime(a,'ConvertFrom','juliandate')
Outputs
25-Aug--2742 10:00:00
Whereas converting from datenum:
datetime(a,'ConvertFrom','datenum')
Outputs
30-Sep-1970 22:00:00
nada
nada 2018 年 6 月 3 日
thank you a lot but i have this error Undefined function 'datetime' for input arguments of type 'double'. my version ( 8.3.0.532 (R2014a) )

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

採用された回答

Star Strider
Star Strider 2018 年 6 月 3 日
I believe those are actually MATLAB datenum numbers. The years do not make sense using 'juliandate' or 'excel' with 'ConvertFrom'.
Try this:
dv = [719801.916666667
719801.958333333
719802];
dta = datetime(dv, 'ConvertFrom','datenum', 'Format','MMMM/dd/yyyy hh:MM:ss')
producing:
dta =
3×1 datetime array
September/30/1970 10:09:00
September/30/1970 10:09:59
October/01/1970 12:10:00
  2 件のコメント
nada
nada 2018 年 6 月 3 日
thank you Star Strider
the same error i found Undefined function 'datetime' for input arguments of type 'double'. my version 8.3.0.532 (R2014a) how it can be work?
Star Strider
Star Strider 2018 年 6 月 3 日
The datetime functions were introduced in R2014b. Since your data appear to be MATLAB datenum numbers, you can use the datestr (link) function to create the strings. See specifically the formatOut (link) section. To use it, you would need to specify:
formatOut = 'mmmm/dd/yyyy HH:MM:SS';

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

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