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
Nish321Nish321 

Calculate number of days between two datetime values in apex

Could someone help me out with this? 

integer dt1 = day( datevalue(cc1.ClosedDate) ) - today();
John Pipkin 14John Pipkin 14
Ramshah, 

Use the daysBetween method in the date class:
Integer dt1 = (system.today()).daysBetween(Date.valueOf(cc1.ClosedDate));

 
Mani Sai GundumogulaMani Sai Gundumogula
Date startDate = Date.newInstance(2008, 1, 1);
Date dueDate = Date.newInstance(2008, 1, 30);
Integer numberDaysDue = startDate.daysBetween(dueDate);
Josué PeixotoJosué Peixoto
Very Good @John Pipkin14.
Does work!!!