Code · Excel and Google Sheets

Julian date formulas for Excel

Worksheet formulas to turn a date into a Julian date (YYYYDDD, YYDDD, YDDD or JD Edwards CYYDDD) and to turn any of those back into a date. The page also covers the astronomical Julian Date (JD, JDN, MJD), Google Sheets, Power Query and DAX. No macros needed.

The formulas most people need

Put a date in A1 (or a Julian code, for the reverse formulas). The examples use July 21, 2026.

TaskFormulaResult
Date → YYYYDDD (number) =YEAR(A1)*1000+A1-DATE(YEAR(A1),1,0) 2026202
Date → YYDDD (text, keeps the zero) =TEXT(A1,"yy")&TEXT(A1-DATE(YEAR(A1),1,0),"000") 26202
YYYYDDD → date =DATE(INT(A1/1000),1,MOD(A1,1000)) 7/21/2026
YYDDD → date (00–29 = 2000s) =DATE(IF(INT(A1/1000)<30,2000,1900)+INT(A1/1000),1,MOD(A1,1000)) 7/21/2026
Today as YYYYDDD =YEAR(TODAY())*1000+TODAY()-DATE(YEAR(TODAY()),1,0) 2026339
Date → day of year =A1-DATE(YEAR(A1),1,0) 202

Format the cells that return a date as Short Date, otherwise Excel shows a serial number such as 46224.

Which “Julian date” do you need?

On labels, in ERP systems and on mainframes, a Julian date is the year plus the day of the year: 2026202 or 26202. In astronomy it is the Julian Date (JD), a running day count such as 2461242.5. Most of this page is about the first kind; the JD section covers the second.

Convert a date to a Julian date

All of these rely on one trick: DATE(YEAR(A1),1,0) is “day 0 of January”, which Excel reads as December 31 of the year before. Subtracting it from the date leaves the day of the year.

Day of year (1–366)

=A1-DATE(YEAR(A1),1,0)

Returns 202 for July 21, 2026. Format the cell as General or Number. The equivalent =A1-DATE(YEAR(A1),1,1)+1 gives the same result.

7-digit Julian date (YYYYDDD)

=YEAR(A1)*1000+A1-DATE(YEAR(A1),1,0)

This returns a real number (2026202) that you can sort, compare and look up. It is always seven digits for years 1000 to 9999, so no padding is needed: January 5, 2026 gives 2026005. If you need text, for example to join it to a lot prefix, use:

=TEXT(A1,"yyyy")&TEXT(A1-DATE(YEAR(A1),1,0),"000")

5-digit Julian date (YYDDD)

The two-digit year is where the leading zero matters: January 5, 2005 should read 05005. The text version keeps it:

=TEXT(A1,"yy")&TEXT(A1-DATE(YEAR(A1),1,0),"000")

If you prefer a number, build it with arithmetic and give the cell the custom number format 00000 so the zero is displayed:

=MOD(YEAR(A1),100)*1000+A1-DATE(YEAR(A1),1,0)
                                   (then Format Cells > Custom > 00000)

4-digit Julian date (YDDD) and JD Edwards (CYYDDD)

The one-digit-year form used on MRE cases and military documents:

=MOD(YEAR(A1),10)&TEXT(A1-DATE(YEAR(A1),1,0),"000")

The JD Edwards form, where the first digit counts centuries since 1900 (126202 for July 21, 2026):

=(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0)

Today’s Julian date

=YEAR(TODAY())*1000+TODAY()-DATE(YEAR(TODAY()),1,0)       -> YYYYDDD
=TEXT(TODAY(),"yy")&TEXT(TODAY()-DATE(YEAR(TODAY()),1,0),"000") -> YYDDD

Excel 365 / Excel 2021 with LET:
=LET(d,TODAY(), YEAR(d)*1000 + d-DATE(YEAR(d),1,0))

TEXT format codes depend on your Excel language

TEXT(A1,"yy") uses English format codes. In a German or Dutch copy of Excel, for example, the year code is JJ. The arithmetic versions (YEAR, MOD, DATE) work in every language, which is why the number formulas are listed first.

Convert a Julian date to a date

The reverse formulas use a different trick: DATE accepts a day number larger than the month and rolls forward, so DATE(2026,1,202) is the 202nd day of 2026, July 21. INT(A1/1000) takes the year part and MOD(A1,1000) the last three digits. Both work whether the code is stored as a number or as text.

YYYYDDD to date

=DATE(INT(A1/1000),1,MOD(A1,1000))

YYDDD to date

=DATE(IF(INT(A1/1000)<30,2000,1900)+INT(A1/1000),1,MOD(A1,1000))

Two-digit years below 30 become 2000–2029 and the rest 1930–1999, the same window Excel uses when you type a date such as 7/21/26. Change 30 if your data needs a different cutoff. Because the formula works on the number, it still reads 5005 correctly when Excel has dropped the leading zero of 05005 (January 5, 2005). Formulas that use LEFT(A1,2) get that case wrong.

Never pass a two-digit year to DATE

Excel adds 1900 to any year from 0 to 1899, so DATE(26,1,202) is July 21, 1926. This is the most common reason a converted Julian date lands in the wrong century.

YDDD, DDD and JDE codes to date

A 4-digit code has only the last digit of the year, so you supply the decade:

=DATE(2020+INT(A1/1000),1,MOD(A1,1000))      decade 2020s
=DATE(2010+INT(A1/1000),1,MOD(A1,1000))      decade 2010s

A bare 3-digit day of year needs the whole year:

=DATE(YEAR(TODAY()),1,A1)                    the current year
=DATE(2025,1,A1)                             a year you know

A JD Edwards CYYDDD value (6 digits, or 5 for 1900s dates):

=DATE(1900+INT(A1/1000),1,MOD(A1,1000))

Codes with letters around them

Lot codes often wrap the Julian date in plant or line letters. Pull the digits out with MID first. For the lot code below, the two-digit year starts at character 2 and the day of year at character 4:

A1: L26202B7     (lot code: letter, YYDDD, letter, digit)

=DATE(2000+MID(A1,2,2),1,MID(A1,4,3))        -> 7/21/2026

Catch invalid days

DATE never complains: DATE(2025,1,366) quietly returns January 1, 2026, and day 000 returns December 31 of the year before. In Excel 365 or 2021, this version flags day numbers that do not exist in that year:

=LET(y,INT(A1/1000), d,DATE(y,1,MOD(A1,1000)),
     IF(AND(MOD(A1,1000)>=1, YEAR(d)=y), d, "invalid day"))

Worked example: July 21, 2026

A1: 7/21/2026   (a real date; Excel stores it as serial 46224)

Day of year       =A1-DATE(YEAR(A1),1,0)                          202
YYYYDDD           =YEAR(A1)*1000+A1-DATE(YEAR(A1),1,0)            2026202
YYDDD             =TEXT(A1,"yy")&TEXT(A1-DATE(YEAR(A1),1,0),"000") 26202
YDDD              =MOD(YEAR(A1),10)&TEXT(A1-DATE(YEAR(A1),1,0),"000") 6202
JDE CYYDDD        =(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0)     126202
Julian Date (JD)  =A1+2415018.5                                   2461242.5
Julian Day Number =INT(A1)+2415019                                2461243
Modified JD (MJD) =A1+15018                                       61242

Format the JD, JDN and MJD cells as Number with the decimals you need, not as Date.

Astronomical Julian Date (JD), JDN and MJD

Excel stores a date as the number of days since December 30, 1899, with the time of day as the fraction. The astronomical Julian Date is the same count with a different starting point, so you only add a constant:

=A1+2415018.5          Julian Date (JD), A1 = date or date and time
=INT(A1)+2415019       Julian Day Number (JDN) of the date in A1
=A1+15018              Modified Julian Date (MJD)

The time of day carries through: 7/21/2026 12:00 gives 2461243.0. The JD day starts at noon UTC, so midnight ends in .5. The Julian Day Number is the whole number for the calendar date (the JD at noon), and the MJD starts at midnight. See the Julian day converter to check a value.

Going back, subtract the same constants and format the cell as a date and time:

=A1-2415018.5          JD  -> Excel date and time
=A1-15018              MJD -> Excel date and time

JD right now

NOW() returns your computer’s local time, but the JD is defined in UTC. Convert to UTC first by subtracting your UTC offset in hours divided by 24 (west of Greenwich the offset is negative, so you add):

=NOW()+5/24+2415018.5     JD now on a computer set to UTC-5 (US Eastern Standard Time)
=NOW()-1/24+2415018.5     JD now on a computer set to UTC+1 (Central European Time)

Remember to change the offset when daylight saving time starts or ends.

Mac workbooks with the 1904 date system

If File > Options > Advanced > Use 1904 date system is ticked (common in workbooks first made on older Macs), day 0 is January 1, 1904 and the constants change:

=A1+2416480.5          JD in a workbook that uses the 1904 date system
=A1+16480              MJD in a workbook that uses the 1904 date system

The day-of-year formulas above are not affected by the date system.

The Excel 1900 leap-year bug

Excel treats 1900 as a leap year and counts a February 29, 1900 that never existed (serial 60). The JD constant is therefore exact only from March 1, 1900, and the day-of-year formulas are one day high from March to December 1900. Excel cannot store dates before 1900 at all. For historical dates, use the converter or the Python code.

Google Sheets

Every formula on this page works in Google Sheets as written, including TEXT, LET and the JD constant 2415018.5. Sheets counts days from the same December 30, 1899 starting point but has no fake leap day, so the JD formula also works for 1900 and for earlier dates (Sheets uses the Gregorian calendar for all of them). Like Excel, Sheets adds 1900 to a year from 0 to 1899 in DATE.

Power Query and Power BI

When the data arrives through Data > Get Data, convert it in Power Query with a custom column:

// Power Query (M): add a custom column
// Date -> YYYYDDD
Date.Year([Date]) * 1000 + Date.DayOfYear([Date])

// YYYYDDD (whole number) -> date
Date.AddDays(#date(Number.IntegerDivide([Code], 1000), 1, 1), Number.Mod([Code], 1000) - 1)

// JDE CYYDDD -> date
Date.AddDays(#date(1900 + Number.IntegerDivide([JDE], 1000), 1, 1), Number.Mod([JDE], 1000) - 1)

In a Power BI or Power Pivot data model, the DAX equivalents are:

-- Power BI / Power Pivot (DAX) calculated columns
YYYYDDD = YEAR([Date]) * 1000 + DATEDIFF(DATE(YEAR([Date]), 1, 1), [Date], DAY) + 1
Date    = DATE(QUOTIENT([Code], 1000), 1, MOD([Code], 1000))
JDEDate = DATE(1900 + QUOTIENT([JDE], 1000), 1, MOD([JDE], 1000))

Make sure the code column is a whole number type first. A text column needs Number.From([Code]) in M or VALUE([Code]) in DAX.

VBA

If you prefer a named function, DatePart("y", d) returns the day of year in VBA:

' VBA: paste into a module (Alt+F11 > Insert > Module), then use =JULIAN7(A1)
Function JULIAN7(d As Date) As Long
    JULIAN7 = Year(d) * 1000 + DatePart("y", d)
End Function

Function FROMJULIAN7(code As Long) As Date
    FROMJULIAN7 = DateSerial(code \ 1000, 1, code Mod 1000)
End Function

Troubleshooting

  • The result is a number like 46224. The cell is formatted as General. Apply a date format.
  • The year comes out as 1926. A two-digit year reached DATE. Add 2000 or 1900 first.
  • The leading zero disappeared. Excel stored 05005 as the number 5005. Use the text formula or the 00000 custom format, and use the INT/MOD reverse formulas, which do not care.
  • #VALUE! The cell holds text that is not a pure number, such as 26-202 or a code with spaces. Clean it with SUBSTITUTE or MID first.
  • The date is one day off near the end of the year. Check whether the year is a leap year: day 366 exists only in leap years, and DATE rolls an invalid day 366 into January 1.

Related

Convert a whole column at once with the bulk converter, print a Julian date calendar, or do the same work in SQL, Python or JavaScript.

Frequently asked questions

What is the Excel formula for a Julian date?

For a date in A1, =YEAR(A1)*1000+A1-DATE(YEAR(A1),1,0) returns the 7-digit YYYYDDD Julian date as a number (2026202 for July 21, 2026). For the 5-digit YYDDD form use =TEXT(A1,"yy")&TEXT(A1-DATE(YEAR(A1),1,0),"000"), which keeps the leading zero (05005 for January 5, 2005).

How do I convert a Julian date to a normal date in Excel?

For a 7-digit YYYYDDD value in A1, use =DATE(INT(A1/1000),1,MOD(A1,1000)) and format the cell as a date. For a 5-digit YYDDD value, add the century: =DATE(IF(INT(A1/1000)<30,2000,1900)+INT(A1/1000),1,MOD(A1,1000)). Both work whether the code is stored as text or as a number, and the 5-digit version still works when Excel has dropped the leading zero (5005 instead of 05005).

Why does my converted Julian date show 1926 instead of 2026?

Excel's DATE function adds 1900 to any year from 0 to 1899, so DATE(26,1,202) means July 21, 1926. Always pass a four-digit year: build it with 2000+ or 1900+ as in the YYDDD formula on this page.

Why does the result look like 46224 instead of a date?

That is Excel's serial number for the date (days since December 30, 1899). The formula is right; the cell is formatted as General or Number. Select it and choose Short Date or Long Date from the Number Format box.

How do I get today's Julian date in Excel?

Use =YEAR(TODAY())*1000+TODAY()-DATE(YEAR(TODAY()),1,0) for YYYYDDD, or =TEXT(TODAY(),"yy")&TEXT(TODAY()-DATE(YEAR(TODAY()),1,0),"000") for YYDDD. TODAY() uses your computer's clock and time zone and updates whenever the workbook recalculates.

Do these formulas work in Google Sheets?

Yes. Every formula on this page works unchanged in Google Sheets. Sheets uses the same day numbering for modern dates, so the JD offset of 2415018.5 is the same too, and Sheets does not have Excel's fake February 29, 1900.

What is the Excel formula for a JD Edwards (JDE) Julian date?

Date to JDE CYYDDD: =(YEAR(A1)-1900)*1000+A1-DATE(YEAR(A1),1,0). JDE CYYDDD to date: =DATE(1900+INT(A1/1000),1,MOD(A1,1000)). The second formula also handles 5-digit values such as 99365 (December 31, 1999).