function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
krios demokrios demo 

How to calculate last fifth date of current month?

I have to send an email alert to the opportunity owner on the last fifth day of the current user....
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Krios,

If you are looking for formula you can use this below formula.
 
IF( MONTH( TODAY() ) = 12,
DATE( YEAR( TODAY() ), 12, 27 ),
DATE( YEAR( TODAY() ), MONTH( TODAY() ) + 1, 1) - 5)

Let me know if you face any issues.

If this solution helps, Please mark it as best answer.

Thanks,
Glenda J. WilsonGlenda J. Wilson
 Hii Good morning all,

This should give you the 5th day (if there is one) ...
DateTime dayInMonth = DateTime.Now; DayOfWeek dayToFind = DayOfWeek.Friday; var fifth= Enumerable.Range(1, DateTime.DaysInMonth(dayInMonth.Year, dayInMonth.Month)) .Select(day => new DateTime(dayInMonth.Year, dayInMonth.Month, day)) .Where(day => day.DayOfWeek == dayToFind) .Skip(4) .FirstOrDefault();




mybkexperience (https://www.mybkexperience.one)