3 Replies Latest reply on Aug 26, 2016 1:32 PM by Andrew Watson

# Current month/current year  '# of days' not getting calculated correctly

Current month/current year  '# of days' not getting calculated correctly.

# of days for current month 2016-08 should be 26 and not 56

• ###### 1. Re: Current month/current year  '# of days' not getting calculated correctly

What are you trying to do there?

I think you might be helped with the MAKEDATE function.

And if you want to find the last day of any month, make a date that is the first day of [Report Month]+1, and then subtract one day.  The "day" portion of the result is the last day of the current month.

Highest day of the current month is, of course, DATEPART('day'. TODAY())

Somehow in your logic above, your current month logic is adding two month's worth of days.  (26 for this month and 30 for next month, I would guess.)  If you use MAKEDATE instead of DATEADD, you just build exactly what you need.

1 of 1 people found this helpful
• ###### 2. Re: Current month/current year  '# of days' not getting calculated correctly

I think it's because you're adding a month to the current month (August) - so instead of having the 26 days to date in August you have 26 days + 30 days where you've added a month.

I expect if you don't add a month when it's the current month and year you'll come out with the answer you want.

That's an educated guess based on the formula, however it's not easy to follow, a packaged workbook would help test.

• ###### 3. Re: Current month/current year  '# of days' not getting calculated correctly

"I think you might be helped with the MAKEDATE function."

Agreed