Solution: Use daysBetween() of Date class.
Syntax: startDate.daysBetween(enddate);
Example:
Date startDate = Date.valueOf('2022-01-1');
Date endDate = system.Today();
Integer numberOfDays = startDate.daysBetween(endDate);
System.debug('Number of Days: '+numberOfDays);
Output:
No comments:
Post a Comment