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>();
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));
2
  • can you look on to this @crmprogdev
    – Pavan tej
    Jun 14, 2016 at 20:13
  • can you look on to this @PepeFloyd
    – Pavan tej
    Jun 14, 2016 at 20:19

1 Answer 1

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.

3
  • can you share any code please @Brian Mansfield
    – Pavan tej
    Jun 14, 2016 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. Jun 14, 2016 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, 2016 at 19:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .