change julian date to format time

조회 수: 12 (최근 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 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