Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Glenn at Mvista

# determine last day of previous month using a date field

For example, using today, can I find the number of days in the month prior to today.

I can find the previous month MONTH(Today()) -1, but what is the last day of that month?

Ideas on how I can do this?

David81

DATE(YEAR(TODAY()),MONTH(TODAY()),1)-1

Might be an easier way, but that one works.

Message Edited by David81 on 03-05-2010 07:12 AM

David81

DATE(YEAR(TODAY()),MONTH(TODAY()),1)-1

Might be an easier way, but that one works.

Message Edited by David81 on 03-05-2010 07:12 AM
This was selected as the best answer
QuinnC

A variation on the last post to get the correct year.  I have tested the first one using one date field to enter a date, and a second formula field to calculate the end of the month. I have not tested the second one for the date of the last day of the previous month.

replace today() with date field or variable:

Selected month:
if(month(today())=12,DATE(year(today())+1,1,1)-1,DATE(year(today()),Month(today())+1,1)-1)

Previous month:
if(month(today())=1,DATE(year(today())-1,12,31),DATE(year(today()),Month(today()),1)-1)