フィルターのクリア

convert Julian Date to yyyy-mm-dd

76 ビュー (過去 30 日間)
Qiming Sun
Qiming Sun 2020 年 10 月 19 日
編集済み: Stephen23 2023 年 7 月 17 日
I am analyzing the vertical profiles of the profiling robotic float ( ftp://ftp.ifremer.fr/ifremer/argo/dac/coriolis/6902905/ ). The dates are there stored as Julian Dates, field JULD. As I was converting them into format yyyy-mm-dd on Matlab, difficulties occurred. The Julian date used here is not as usual (first 2 digits year and last 3 digits days w.r.t. Jan 1st, nor the number of days w.r.t. 4713 BCE ). For example here 25856 represents 17-Oct-2020, which is confusing to me. Could someone please provide some instruction on this? Thank you very much!
  1 件のコメント
James Tursa
James Tursa 2020 年 10 月 19 日
Can you explain how 25856 represents 17-Oct-2020? If the "first 2 digits year" is 25, how does that and 856 days result in a date in 2020?

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

採用された回答

meghannmarie
meghannmarie 2020 年 10 月 19 日
編集済み: meghannmarie 2020 年 10 月 19 日
Your number represents "days since 1950-01-01 00:00:00 UTC". Most netcdf times are stored like this, you need to look at attribute on the time field in the netcdf file to so see whether it is hours since or days since and the date of origin. To convert do this:
epoch = datetime(1950,01,01);
time = epoch + days(jd);
  1 件のコメント
Stephen23
Stephen23 2023 年 7 月 17 日
編集済み: Stephen23 2023 年 7 月 17 日
+1 Possibly CALDAYS is required:
D = datetime(1950,01,01, 'Format','u-MM-dd HH:mm:ss') + caldays(25856)
D = datetime
2020-10-16 00:00:00

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

その他の回答 (1 件)

Adam Danz
Adam Danz 2020 年 10 月 19 日
編集済み: Adam Danz 2020 年 10 月 23 日
Are you looking for this?
datetime(25856,'convertfrom','juliandate','Format','yyy-MM-dd')
ans = datetime
4643-09-09
which makes sense given,
datetime(0,'convertfrom','juliandate','Format','yyy-MMM-dd') + days(25856)
ans = datetime
4643-Sep-09
Inspired by this answer.

カテゴリ

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