KNOWLEDGE BASE

How To Calculate Number Of Days In Month


Published: 12 Apr 2021
Last Modified Date: 21 Apr 2021

Question

How to calculate number of days in each month?

Environment

  • Tableau Desktop

Answer

Create a calculated field including the following formula. In this formula, the DATETRUNC function returns the first date of the current month and the DATEADD function adds 1 month to the first date of current month. Then, minus 1 day from the date to get the last date of the current month and the number of days is available by the DATE function.
DAY(DATEADD('day',-1,DATEADD('month',1,DATETRUNC('month',[<Date Field>]))))
Did this article resolve the issue?