# How to calculate nth day of year in Excel

To get the nth day of year based on a given date, you can use a formula based on the DATE and YEAR functions.

## Formula

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

## Explanation

In the example shown, the formula in C5 is:

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

With the date “June 1, 2016” in cell B4, the formula returns 153, since June 1st is the 153rd day of that year.

### How the formula works

This formula takes advantage of the fact that dates are just sequential numbers in Excel. It determines the last day of the previous year and subtracts that value from the original date B4. The result is nth day of the year.

Note the day argument in DATE is supplied as zero. A nice feature of DATE function is it can handle DAY values that are “out of range” and adjust the result appropriately. When we give DATE a year, a 1 for month, and zero for DAY, the DATE function returns the last day of the previous year.

### Day of year as of today

To adjust the formula to return the nth day of year for the current date, just use the TODAY function for the date:

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