change julian date to format time

10 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by