For developers
Julian Dates in Code
Copy-paste formulas and functions for both kinds of Julian date — the day-of-year code and the astronomical Julian Date — in the tools you actually use. Each snippet is verified against known reference values.
Excel
YYDDD and YYYYDDD both ways, JDE, JD and MJD, plus Google Sheets, Power Query and DAX.
Python
strftime %j, parsing codes, pandas columns, and a tested JD function with its inverse.
JavaScript
Day of year in UTC, local time or any time zone (Intl, Temporal), and JD from a Date.
SQL
SQL Server, Oracle, PostgreSQL, MySQL, SQLite, Db2, BigQuery, Snowflake and Spark.
SAS
JULDATE7, DATEJUL, the JULIAN format and informat, and JD = date + 2436934.5.
Java & C#
java.time and DateOnly: day of year, ofYearDay, JulianFields and DayNumber.
Two conversions, everywhere
Every page covers the same two tasks in its language:
- Day-of-year (ordinal) Julian date: turn a date into
YYYYDDD,YYDDDor the JD EdwardsCYYDDDform, and back. - Astronomical Julian Date: turn a date and time into
JD,JDNandMJD, and back.
Every format for one date
Use these values for July 21, 2026 to test your own code:
| Format | Value | What it is |
|---|---|---|
| Day of year | 202 | Position in the year, 1–366 |
| YYYYDDD | 2026202 | Four-digit year + day of year |
| YYDDD | 26202 | Two-digit year + day of year |
| YDDD | 6202 | Last digit of the year + day of year (MRE, military) |
| CYYDDD | 126202 | JD Edwards: centuries since 1900 + YY + DDD |
| Julian Day Number | 2461243 | Astronomical day count for the date |
| Julian Date (JD) | 2461242.5 | Same count with the time of day (00:00 UTC here) |
| Modified JD (MJD) | 61242 | JD − 2400000.5, starts at midnight |
Prefer not to write any code? The on-site converter does both instantly in your browser.
A note on accuracy
The astronomical snippets use the standard algorithm from Jean Meeus and agree on the key anchors: the Unix epoch (JD 2440587.5), the MJD epoch (JD 2400000.5) and J2000.0 (JD 2451545.0). Watch out for time-zone and day-boundary details — the pages flag the common traps in each language.