A simple formula for date return of last day of current month? - Answers - Salesforce Trailblazer Community
ShowAll Questionssorted byDate Posted
RAKESH GUPTA

# A simple formula for date return of last day of current month?

Best Answer chosen by RAKESH GUPTA
Sourav Dutta
Hi Rakesh,

Try This:
```IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1)```

Best Regards,
Sourav​

RAKESH GUPTA

DATE(
YEAR( TODAY() ) ,
Month( TODAY()),
CASE( MONTH(TODAY()),
1, 31,
2, IF( MOD( YEAR(TODAY()) , 4) = 0, 29, 28),
3, 31,
4, 30,
5, 31,
6, 30,
7, 31,
8, 31,
9, 30,
10, 31,
11, 30,
12, 31,
0
)
)

Sourav Dutta
Hi Rakesh,

Try This:
```IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 31 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 1)```

Best Regards,
Sourav​
This was selected as the best answer
Naveen Dhanaraj
Simply Like This,
```IF(
MONTH( date ) = 12,
DATE( YEAR( date ), 12, 31 ),
DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1
)```
https://help.salesforce.com/articleView?id=formula_examples_dates.htm&type=0

Telmo Batista
New way:

Best Regards

Hello, I had workflow based on this formula working perfectley fine until this month (December). Now I get this error:

Formula evaluation error in Custom Link Renewal
Month or Day out of range in DATE() function

My formula is: DATE(YEAR(TODAY()),MONTH(TODAY()) + 1,1) - 1

I even tried Telmo's formula above but to no avail

Telmo Batista
I Marc,

Your formula is breaking in year.

What do you mean with "I even tried Telmo's formula above but to no avail" ??