Play Games

Search This Blog

Thursday, February 3, 2022

Find the number of days between two given dates in Salesforce - Salesforce Globe For You

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