# Thread: Trying to find month/day from day of year

1. ## Trying to find month/day from day of year

So in one of our assignments we have to have someone input the day of the year (ex. 59) and have it output the month and day (ex. 2/28). All we have to work with is an array that declares how many days are in each month.

I thought I had it beat with this code (for February):

Code:
```else if((daysNmonth[1] + daysNmonth[2]) - dayOfYear >= 0)
{
dayOfMonth = daysNmonth[1] + daysNmonth[2] - dayOfYear;
Month = 2;
printf("Day %d of the year is %d/%d", dayOfYear, Month, dayOfMonth);
}```
But then I realized it's counting backwards! For example, putting in 57 gives me 2/2. Is there an easier way to do this?

2. So your daysInMonth variable needs to be how large, do you think?

And what else do you think you need to do?

--
Mats

3. Well my DaysNmonth is already defined, an array of 13 objects, because daysNmonth[0] is set to 0, and we ignore it. So daysNmonth[1] - daysNmonth[12] = the days of the month, such as 31, 28, etc..

4. Ok, and how are you going to know which month it is that you want? If you have 100 days into the year, how do you figure out that this means April?

--
Mats