How to find number of days between two Dates in Apex?

Sample Code:

public Integer temp;

public Date d {get ; set;}

temp = d.daysBetween(Date.Today()); // Returns Number of days between d and today.

4 comments:

  1. how to calculate number of days between two dates excluding the weekens like 'Salturday' and 'Friday'

    ReplyDelete
    Replies
    1. Check this - https://help.salesforce.com/articleView?id=000004526&type=1

      Delete
  2. how to calculate number of days between two days excluding weekends like Saturday and Sunday

    ReplyDelete
    Replies
    1. Check this - https://help.salesforce.com/articleView?id=000004526&type=1

      Delete