Excel guide · 6 min read
How to convert Julian dates and get the day of year in Excel
=A2-DATE(YEAR(A2),1,0): 14 Feb 2026 gives 45. For a 5-digit Julian code (YYDDD) use =TEXT(A2,"yy")&TEXT(A2-DATE(YEAR(A2),1,0),"000"), which gives 26045. To turn a code like 26045 back into a date, use =DATE(2000+LEFT(B2,2),1,RIGHT(B2,3)).Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | |
|---|---|---|---|
| 1 | Packed on | Lot code (YYDDD) | JDE date (CYYDDD) |
| 2 | Feb 14, 2026 | 26045 | 126045 |
| 3 | Mar 1, 2024 | 24366 | 99365 |
| 4 | Mar 1, 2026 | 27005 | 2026305 |
| 5 | Dec 31, 2024 | 5032 | |
| 6 | Jan 5, 2027 |
Download this sheet as an Excel practice file (.xlsx)
Day of the year from a date
DATE(YEAR(A2),1,0) asks for "day 0 of January", which Excel rolls back to 31 December of the year before. Subtract that from the date and you get its position in the year: 1 for 1 January, 45 for 14 February. =A2-DATE(YEAR(A2),1,1)+1 gives the same answer if you find it easier to read.
Leap years are handled for you, because Excel works from the real calendar. 1 March is day 60 in 2026 but day 61 in 2024, and 31 December 2024 is day 366. Never hard-code a table of month offsets; it is wrong one year in four.
If the answer shows as a date such as 14/02/1900, Excel has copied the date format from A2. Change the cell to General (Home > Number Format > General). For the current day of the year, use =TODAY()-DATE(YEAR(TODAY()),1,0).
Result: 45
45: Saturday 14 February 2026 is the 45th day of the year.
Days left in the year, and days in the year
The same idea works from the other end. =DATE(YEAR(A2),12,31)-A2 counts the days still to come after the date: 320 after 14 February 2026. That is handy for pro-rating an annual fee or a leave allowance.
To know whether a year has 365 or 366 days, subtract 1 January from the next 1 January: =DATE(YEAR(A3)+1,1,1)-DATE(YEAR(A3),1,1) returns 366 for 2024. Use this instead of dividing by 365 when the exact year length matters.
Result: 320
320 days remain in 2026 after 14 February (45 + 320 = 365).
Date to a YYDDD or YYYYDDD Julian code
In food packing, pharma, the military and many warehouses, a "Julian date" just means year plus day of year: 26045 is the 45th day of 2026. Excel has no format code for the day of the year, so you build the code with TEXT.
The "000" format is the part people miss. Without it, 5 January 2027 becomes "27" & 5 = "275", which reads back as day 275 of 2027. TEXT(...,"000") pads the day to three digits, giving 27005. For the 7-digit YYYYDDD form, swap TEXT(A2,"yy") for YEAR(A2): =YEAR(A2)&TEXT(A2-DATE(YEAR(A2),1,0),"000") returns 2026045.
The result is text, which is what you want for a code: it keeps every digit and lines up with the label printer. If a system needs it as a number, wrap it in VALUE.
Result: 26045
26045: year 26, day 045. The same formula gives 27005 for 5 January 2027.
Julian code back to a date
DATE accepts a day number larger than the month has, and rolls forward: DATE(2026,1,45) is 14 February 2026. So a code converts in one step. LEFT takes the year digits and RIGHT the day digits: =DATE(2000+LEFT(B2,2),1,RIGHT(B2,3)) returns Saturday 14 February 2026. For a 7-digit code use =DATE(LEFT(C4,4),1,RIGHT(C4,3)), which turns 2026305 into 1 November 2026.
Do not leave out the 2000+. DATE treats a year from 0 to 1899 as an offset from 1900, so DATE(26,1,45) is 14 February 1926 and the 27005 lot becomes 5 January 1927, with no error. For codes from the 1990s, decide on a cut-off, for example =DATE(IF(LEFT(B2,2)+0>50,1900,2000)+LEFT(B2,2),1,RIGHT(B2,3)).
Check the day part too. Day 366 only exists in leap years: 24366 is 31 December 2024, but a typo like 25366 quietly becomes 1 January 2026. To catch it, test that YEAR of the result still matches the year in the code.
Result: Sat 14 Feb 2026
Sat 14 Feb 2026. TEXT is only for display here; drop it to keep a real date you can sort and subtract.
Codes that lost their leading zero (and JDE dates)
Codes from 2000 to 2009 start with 0, and Excel drops it as soon as the column is a number: "05032" (1 February 2005) arrives from a CSV as 5032. LEFT(5032,2) is then "50", and the formula above returns 1 February 2050. The arithmetic version does not care about digits: INT(B5/1000) is the year part and MOD(B5,1000) is the day part, so it works on text codes, numbers and lost zeros alike.
JD Edwards (JDE) and some AS/400 systems store dates as CYYDDD, where C is the century: 0 for the 1900s, 1 for 2000 onwards. 126045 is 14 February 2026, and 31 December 1999 is 099365, which Excel shows as 99365. Because the century digit sits in front of the year, one formula covers both: =DATE(1900+INT(C2/1000),1,MOD(C2,1000)). Going the other way, =(YEAR(A2)-1900)*1000+A2-DATE(YEAR(A2),1,0) turns 14 February 2026 into 126045.
To keep codes intact on import, set the column to Text in the Text Import or Power Query step, or format the column as Text before you paste. To show a number with its zero again, use =TEXT(B5,"00000").
Result: 1 Feb 2005
1 Feb 2005: the correct date for the code 05032, where the LEFT/RIGHT version gives 1 Feb 2050.
Astronomers' Julian Day is something else
Astronomy, satellite tracking and some scientific data use the Julian Day (JD): a running count of days since 4713 BC, with each day starting at noon UTC. It has nothing to do with YYDDD codes. 14 February 2026 at midnight UTC is JD 2461085.5.
Excel's date serial numbers are a running count too, so the conversion is a fixed offset for dates from 1 March 1900 onwards: JD = date + 2415018.5. Format the result as a number with one decimal, or Excel may show it as a date. For the whole-number Julian Day Number of the day, add 2415019 instead (2461086). For the Modified Julian Date used in many data files, add 15018 (61085). To go back, subtract the same offset and format as a date.
"Julian" can also mean the old Julian calendar, which runs 13 days behind ours. Excel has no function for that calendar, so if your source mentions it, check before you convert.
Result: 2461085.5
2461085.5: the Julian Day at 00:00 UTC on 14 February 2026.
Common mistakes
Building the code without "000"
Day 5 becomes "5", so 5 January 2027 turns into 275. Always pad the day with TEXT(day,"000").
DATE(LEFT(code,2),1,RIGHT(code,3)) without 2000+
DATE reads year 26 as 1926. Add 2000 (or 1900 for a 1990s cut-off) to two-digit years.
Codes stored as numbers lose the leading zero
Use the INT(code/1000) and MOD(code,1000) version, which works whether the zero is there or not, and import code columns as Text.
Mixing up lot-code Julian dates with the astronomical Julian Day
A 5- or 7-digit code is year plus day of year. A 7-digit number starting with 24 and ending in .5 is a Julian Day; use the 2415018.5 offset.
FAQ
How do I convert a 5-digit Julian date to a normal date in Excel?
Use =DATE(2000+LEFT(A2,2),1,RIGHT(A2,3)) and format the cell as a date. If some codes lost a leading zero, use =DATE(2000+INT(A2/1000),1,MOD(A2,1000)) instead.
How do I get the day number of the year in Excel?
Use =A2-DATE(YEAR(A2),1,0). It returns 1 to 365, or 366 in a leap year. Set the cell to General if the result shows as a date.
How do I show today's Julian date in Excel?
Use =TEXT(TODAY(),"yy")&TEXT(TODAY()-DATE(YEAR(TODAY()),1,0),"000") for YYDDD. It updates each day, so copy and Paste Values if you need to keep the code for a batch record.
Is there a Julian date format in Excel?
No. Number formats cannot show the day of the year, so the code has to be built with a formula like the TEXT one above. The result is text, which keeps the leading zeros in the day part.
How do I convert a JDE date in Excel?
JDE stores dates as CYYDDD, such as 126045. Use =DATE(1900+INT(A2/1000),1,MOD(A2,1000)), which handles both 1900s and 2000s dates.
Functions used
DATEBuilds a dateYEARYear of a dateTEXTNumber to formatted textLEFTCharacters from the startRIGHTCharacters from the endINTRounds down to integerMODRemainder after divisionTODAYToday’s dateVALUEText to numberIFPicks a result from a test
Related guides
- How to convert text to a date in Excel
- How to convert a date to text in Excel
- How to add leading zeros in Excel
- How to convert numbers stored as text in Excel
- How to get the week number from a date in Excel
- How to get the first day of the month in Excel
- How to make negative numbers positive in Excel
Updated