+ Start a Discussion

Dynamic Serach Date field

This is in regards to dynamic search .

I have two date fields

When i print the SOQL , the Date fields as seen from the soql below are string.

I tried converting to date in the format 1-12-2014 but have been unsuccessful.

any ideas? Thanks.

Debug - SOQL

select Name,Branch__c,  Order__c,Status__c,TC_Date__c,Report_Date__c from Transaction__c Where Transaction__c.name!=null and Branch__c LIKE '%' and Report_Date__c = '1/12/2014' order by Branch__c asc limit 1000
Mariappan PerumalMariappan Perumal
Hi .

I think Date format in the query will be like this 2014-01-01 don't put that in quotes

Try this it may help you .

 tried this but getting an error -

String weekenddate = Apexpages.currentPage().getParameters().get('weekenddate');
Date mydate = Date.parse(weekenddate);

if (!weekenddate.equals(''))
                soql += ' and T_C_Date__c = :mydate';

// Error Variable does not exist mydate

Mariappan PerumalMariappan Perumal

String weekenddate = Apexpages.currentPage().getParameters().get('weekenddate');
weekendate should be in this format  :mm/dd/yyyy 

Date .parse () method can only take string in the above format.
Make sure your weekendate is in the above format before passing this to parse method.

Hope the above information is useful to you . 

Kindly let me know if you still have the error persist.