ANS-0087 · SAVED SEARCHES & FORMULAS

How to Calculate the Number of Days in a Month in NetSuite

NetSuite users can determine the exact number of days for any given month using a simple date calculation formula.

Short answer

To calculate the number of days in a month within NetSuite, apply the formula LAST_DAY({trandate}) - TRUNC({trandate},'MONTH')+1. This formula subtracts the first day of the month from the last day, then adds one to account for all days.

Scenario

NetSuite users often need to determine the precise number of days within a specific month for reporting, custom fields, or other calculations. This requirement arises when building custom solutions that depend on accurate monthly date ranges.

Solution

To obtain the number of days in a month in NetSuite, utilize the following formula: LAST_DAY({trandate}) - TRUNC({trandate},'MONTH')+1. The LAST_DAY({trandate}) component identifies the last day of the month. The TRUNC({trandate},'MONTH') component identifies the first day of the month. Subtracting the first day from the last day provides the difference between the two dates. Adding +1 to this difference yields the total number of days in the month. While {trandate} is used in this example, any valid date value can be substituted.

Expert NetSuite Support

Need help with this NetSuite issue?

Saved Searches & Formulas consulting and configuration support

Talk to a consultant