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

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

Use the daysBetween method in the date class:
Integer dt1 = (;

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!!!