Some time you may
need to calculate the total number of Days in a month from the given input
date. For example suppose if the given
date is 05/04/2014(DD/MM/YYYY) means the total number of days in a month will
need to return as 31 Days. This can be done by using daysInMonth method.
daysInMonth - Returns the number of days in the
month for the specified year and month (1=Jan) the following example finds the
number of days in the month of February in the year 1960.
Here is the sample code,
1 | Date d = System .today(); |
2 | Integer numberDays = date.daysInMonth(d.Year(), d.Month()); |
3 | System .debug(numberDays); |
Reference: Date
Methods in Salesforce
No comments:
Post a Comment