Convert date to specific format julian date
Ältere Kommentare anzeigen
Need to convert calendar date to Julian date in a specific format (YYDDD). Ex: Day = (2016-05-04,2016-08-24,2016-12-31) J-Day = (16125,16237,16366)
Any help would be appreciated. Thanks.
Akzeptierte Antwort
Weitere Antworten (4)
Steven Lord
am 3 Okt. 2016
0 Stimmen
Create a datetime array from the char vectors containing the yyyy-MM-dd form of the dates. Use the juliandate function to compute the Julian date from the datetime array.
1 Kommentar
Charlie Wood
am 3 Okt. 2016
Bearbeitet: Charlie Wood
am 3 Okt. 2016
Michael C.
am 3 Okt. 2016
My understanding was that Julian usually referred to the number of days since Jan 1 4713 BC, but judging by your example, you are using March 11th, 1972.
Either way, you can get number of days by doing a subtraction on two "datenum"s
datenum([2016 08 24 0 0 0]) - datenum([1972 3 11 0 0 0])
which gives the 16237. Passing in a string for the date will also work.
1 Kommentar
Charlie Wood
am 3 Okt. 2016
Charlie Wood
am 3 Okt. 2016
Ankit Kanthe
am 3 Okt. 2016
0 Stimmen
Here's what I got combining some answers:
d = '2016-05-04'; dt = datime(d); jday = (year(dt)-2000)*1000 + day(dt,'dayofyear') The answer comes out with 16125. It's not pretty and not useful for dates before the year 2010 (maybe with some minor formatting it would be ok for 2000-2009). It does however work for my 2014-2016 dates so far.
Kategorien
Mehr zu Time Series Objects finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!