The daysBetween() method can be used to find number of days between two dates.
Example:
Integer noOfDays = startDate.daysBetween( endDate );
Execute the following sample code in Developer Console to view the output:
Sample Code:
Date startDate = Date.today();
Date endDate = Date.today().addDays( 90 );
Integer noOfDays = startDate.daysBetween( endDate );
system.debug( 'Output is ' + noOfDays );