0

I need to calculate days between two fields.

So I use daysBetween to complete when I try to do with two dates. When I try with single values.

But, when I try with list it throws an error like:

Method does not exist or incorrect signature: [Date].daysBetween(List)

For reference my code:

public date closedates;
Public Long details;
List<Case> c=new List<case>();
List<Integer> Values=new List<Integer>();
//Integer Value=0;
List<Date> Churndate=new List<Date>();
List<Date> closedatesd=new List<Date>();
c=[Select Id,Date_Order_Received__c,accountId from case where RecordTypeId =      
'01290000000sF3L'];
System.debug('Data in Case '+c);
List<Id> accountIds= new List<Id>();
List<Account> accounts=new List<Account>();
List<Id> opps=new List<Id>();
List<Date> Oppsdate= new List<Date>();
for(Case cl:c) 
{
accountIds.add(cl.accountId);
//Churndate=cl.Date_Order_Received__c;
Churndate.add(cl.Date_Order_Received__c);
}
System.debug('Date value in '+churndate);
for(Account ao:[Select Id,name,(select Id,name,CloseDate from opportunities)   
from account where Id in:accountIds]) {
for(Opportunity opp : ao.opportunities)
{
   opps.add(opp.Id);
   //details=closedates.daysBetween(Churndate);
   **Values.add(opp.CloseDate.daysBetween(Churndate));**
   //Other Operation you want to perform with every opportunity
}
}

Error line:

Values.add(opp.CloseDate.daysBetween(Churndate));
  • can you look on to this @crmprogdev – Pavan tej Jun 14 '16 at 20:13
  • can you look on to this @PepeFloyd – Pavan tej Jun 14 '16 at 20:19
5

Churndate is a List<Date>, the method expects a single Date.

From glancing at your code, it looks like you either want to create a Map<Id, Date> with the Accounts you're iterating over and use .get(AccountId) to fetch the relevant Date, or use an index to slice the right Date out of Churndate.

|improve this answer|||||
  • can you share any code please @Brian Mansfield – Pavan tej Jun 14 '16 at 19:42
  • Sorry but no - if you are capable to author the above code, this is most definitely within your abilities. If you have a specific question or if you get stuck at any point, you can ask a new question. – Brian Mansfield Jun 14 '16 at 19:43
  • i tried it.It doesn't works for testing purpose i tried only take churndate in a single date variable. it throws me same error.I had already mentioned when i check with single variables it is working fine.@Brian Mansfield can you look on to this – Pavan tej Jun 14 '16 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.