Step 1: Create a Formula Field (Number)
Step 2: Paste this formula : DAY(DATE(YEAR(TODAY()),MONTH(TODAY())+1,1)-1)
Function :
Where MONTH(TODAY()) is the month for which you want to return the number of days, and YEAR(TODAY()) is the year. This function calculates the first day of the next month and subtracts 1, which equals the last day of the current month. The DAY function then gives you the day of the month.
Thank you for the formula. The problem is that in December, MONTH(TODAY())+1 equals 13, which is invalid, and causes an error. How would you handle that problem?
ReplyDeleteReceiving that error now, any solution? What about an IF statement and "12"? Thoughts
ReplyDeleteIF(
ReplyDeleteMONTH( date ) = 12,
DATE( YEAR( date ), 12, 31 ),
DATE( YEAR( date ), MONTH ( date ) + 1, 1 ) - 1
)
Yes it's December now and i'm having this issue! The IF formula doesn't seem to work.....help!
ReplyDeleteIF(
DeleteMONTH( TODAY() ) = 12,
31,
DAY(
DATE( YEAR( TODAY() ), MONTH ( TODAY() ) + 1, 1 )
- 1 )
)
sfdcGeek's formula returns the last day of the specified month as a date, my formula returns the last day of the current month as a number.
DeleteVery good man..kudos !!!
DeleteThis comment has been removed by the author.
ReplyDelete