Hi All,     This post explains how to  calculate time spent and no of days between two date time value and issue faced while doing same and how to resolve those.     First Try    Account acc = [select id,createddate,lastmodifieddate from Account limit 1];     datetime diff = acc.lastmodifieddate - acc.createddate;   System.debug('diff --'+diff );     Error -  COMPILE ERROR: Date/time expressions must use Integer or Double or Decimal LINE: 3 COLUMN: 14        Second Try      Account acc = [select id,createddate,lastmodifieddate from Account limit 1];     Integer diff = Integer.valueOf(acc.lastmodifieddate) - Integer.valueOf(acc.createddate);   System.debug('diff --'+diff );     Error   EXCEPTION: System.TypeException: Invalid integer: java.util.GregorianCalendar[time=1455789326000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=2,mi...
A place where you have to land for exploring Salesforce