0
 Integer BPcurrentYear = System.Today().year();
    List<Business_Plan__c> lBPs = [Select b.Year__c,  b.FCPA_Last_Updated__c, 
        (Select Name,IsHQ__c 
        FROM Business_Plan_Details__r WHERE Type__c = 'Current Year Revenue Goal') 
        FROM Business_Plan__c b WHERE Partner_Account__c = :accInstance.Id and b.Status__c = 'Approved' AND b.Year__c = :BPcurrentYear
        ORDER BY b.Year__c DESC ];

From abive query i'm getting error:

Invalid bind expression type of Integer for column of type String

I'm having problem with b.Year__c = :BPcurrentYear

Here the b.Year__c is Text Field. I am comparing with integer.

How to compare the Text field with integer or should i take take Current year in any other format which can assign to Text field?

2
  • String.valueOf may help you to get current year as string – kurunve Aug 22 '16 at 7:44
  • yes i did this Datetime dt = Datetime.NOW(); string BPcurrentYear = String.valueOf(dt.year()); Now it is working. Thank you very much – user24737 Aug 22 '16 at 7:58
3

You need to pass String value for Year__c field:

String BPcurrentYear= String.valueOf(system.today().year());

Your Answer

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