function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
andy1234andy1234 

Number of days within date range?

 Hello,

    Can anybody tell how to get number of days within a given date range(date fields) in APex?

 

Thanks

Richie DRichie D

date startDate = date.newInstance(2008, 1, 1) ; //or yourObject.DateField

date dueDate = date.newInstance(2008, 1, 30) ; //or yourObject.DateField

integer numberDaysDue = startDate.daysBetween(dueDate) ;

 

Have a look at

Date Methods

 

R.

andy1234andy1234
Thanks! got it