Skip to main content
reword to allow for embedding hyperlink in answer
Source Link

Apex provides a native daysBetween instance method on Date (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htmDate instance method), daysBetween().

date startDate = 
 date.newInstance(2008, 1, 1);
date dueDate = 
 date.newInstance(2008, 1, 30);
integer numberDaysDue = 
 startDate.daysBetween(dueDate);

In your case it would be

temp_LatestGapLen = temp_PB_CurrSubBeg.daysBetween(temp_PrevSubEnd);

Apex provides a native daysBetween instance method on Date (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm)

date startDate = 
 date.newInstance(2008, 1, 1);
date dueDate = 
 date.newInstance(2008, 1, 30);
integer numberDaysDue = 
 startDate.daysBetween(dueDate);

In your case it would be

temp_LatestGapLen = temp_PB_CurrSubBeg.daysBetween(temp_PrevSubEnd);

Apex provides a native Date instance method, daysBetween().

date startDate = 
 date.newInstance(2008, 1, 1);
date dueDate = 
 date.newInstance(2008, 1, 30);
integer numberDaysDue = 
 startDate.daysBetween(dueDate);

In your case it would be

temp_LatestGapLen = temp_PB_CurrSubBeg.daysBetween(temp_PrevSubEnd);
Source Link
techtrekker
  • 18.4k
  • 1
  • 45
  • 50

Apex provides a native daysBetween instance method on Date (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_date.htm)

date startDate = 
 date.newInstance(2008, 1, 1);
date dueDate = 
 date.newInstance(2008, 1, 30);
integer numberDaysDue = 
 startDate.daysBetween(dueDate);

In your case it would be

temp_LatestGapLen = temp_PB_CurrSubBeg.daysBetween(temp_PrevSubEnd);