0

visualforce page:

<apex:inputText value="{!inputText6}" size="20"   id="teja2" onfocus="DatePicker.pickDate(false, 'page1:form1:teja2', false);" />
    <apex:inputText value="{!inputText5}" size="20" id="teja1" onfocus="DatePicker.pickDate(false, 'page1:form1:teja1', false);" />

controller:

 public string inputText5{get;set;} // input text1 value  from vf
     public string inputText6{get;set;} // input text2 value  from vf  
public void showlist(){ //do not return anything
      string query='select Quote_Line_Item__r.Quote1__r.from1__c,Quote_Line_Item__r.Quote1__r.Order_Received__c,Quote_Line_Item__r.Quote1__c,Quote_Line_Item__r.Name,Quote_Line_Item__r.N_EP_DPI__c, Asked_Qty__c,MOD_Maxi__c, Unit_Price__c, Max_Quantity__c,batch_value__c,Quote_Line_Item__r.Client_P_N__c,Quote_Line_Item__r.Description__c,Quote_Line_Item__r.Quote1__r.Quote_number_new__c,Quote_Line_Item__r.Quote1__r.name,Quote_Line_Item__r.Quote1__r.Account_Name__c,Quote_Line_Item__r.Quote1__r.Quote_Validity__c,Quote_Line_Item__r.Quote1__r.RFQ_Date__c,Quote_Line_Item__r.Quote1__r.createddate__c,Quote_Line_Item__r.Quote1__r.account_code__c  from  batch__c ';
      String[] filters = new String[0];
  if(string.isnotblank(inputtext5)) {
    filters.add(' Quote_Line_Item__r.Quote1__r.RFQ_Date__c ' + operator4 + ' : inputText5');
      }
           if(string.isnotblank(inputtext6)) {
    filters.add('Quote_Line_Item__r.Quote1__r.createddate__c ' + operator5 + ' : inputText6');
      }

I am getting error from while querying :

System.QueryException: Invalid bind expression type of String for column of type Date Error is in expression '{!showlist}' in component in page customreport

How can i change the format i am getting format as dd/mm/yyyy

1 Answer 1

2

The error says it all, you have to convert inputText5,inputText6 to date using date.valueOf('your date string') or you can use date.newInstance method. And one more thing your going to use database.query so after converting a string to date format you need covert it again to string to use in to your query

Have a look at the apex datetime methods

public string inputText5{get;set;} // input text1 value  from vf
     public string inputText6{get;set;} // input text2 value  from vf  
public void showlist(){ //do not return anything
      string query='select Quote_Line_Item__r.Quote1__r.from1__c,Quote_Line_Item__r.Quote1__r.Order_Received__c,Quote_Line_Item__r.Quote1__c,Quote_Line_Item__r.Name,Quote_Line_Item__r.N_EP_DPI__c, Asked_Qty__c,MOD_Maxi__c, Unit_Price__c, Max_Quantity__c,batch_value__c,Quote_Line_Item__r.Client_P_N__c,Quote_Line_Item__r.Description__c,Quote_Line_Item__r.Quote1__r.Quote_number_new__c,Quote_Line_Item__r.Quote1__r.name,Quote_Line_Item__r.Quote1__r.Account_Name__c,Quote_Line_Item__r.Quote1__r.Quote_Validity__c,Quote_Line_Item__r.Quote1__r.RFQ_Date__c,Quote_Line_Item__r.Quote1__r.createddate__c,Quote_Line_Item__r.Quote1__r.account_code__c  from  batch__c ';
      String[] filters = new String[0];
inputText5=string.valueOfGmt(date.newInstance(inputText5.split('/')[2], inputText5.split('/')[1], inputText5.split('/')[0]));
inputText6=string.valueOfGmt(date.newInstance(inputText6.split('/')[2], inputText6.split('/')[1], inputText6.split('/')[0]));

  if(string.isnotblank(inputtext5)) {
    filters.add(' Quote_Line_Item__r.Quote1__r.RFQ_Date__c ' + operator4 +  inputText5);
      }
           if(string.isnotblank(inputtext6)) {
    filters.add('Quote_Line_Item__r.Quote1__r.createddate__c ' + operator5 +  inputText6);
      }
0

You must log in to answer this question.

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