Converting fractional doy (eg. 208.572917) to a date with mm/dd/yyyy HH:MM

I have a set of data that includes doy for the year, 2013, but the doy are fractions such that July 27th at 13:45 would be represented as 208.5729167. I would like to convert this to a visual that is easier to interpret such as mm/dd/yyyy HH:MM. I've searched around and the closest function I've found converts a date to doy.
Thanks in advance

 채택된 답변

datestr(208.5729167 + datenum('2013/01/01'),'mm/dd/yyyy HH:MM')

댓글 수: 1

Works great, thank you! Only correction I have is that instead of 2013/01/01, 2012/12/31 should be used because this gives the accurate date since doy 208 already accounts for the 1st of the year.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

In R2014b or later, you can use datetime and duration:
>> d = datetime(2013,1,1) + days(208.5729167)
d =
28-Jul-2013 13:45:00
But bear in mind that in double precision, hours, minutes, and seconds are not exactly representable as fractions of days. Hope this helps.

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

태그

질문:

2015년 7월 27일

답변:

2015년 7월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by