Sunday, 29 July 2012

Date comparison in dynamic query

Hello EveryOne,

This is my first blog and hope this will be help to fresher who are new on salesforce.
Today i learn how fetch the list of record by using of dynamic query with date field camparison.
I got successfully list based on date field criteria.so i am publish this.

Object Api Name  : MyCustomObject__c;
Custom field date type : start_date__c;

List<sObject> myRecords = new List<myObject__c>();

Date dateForCamparsion = System.Today();

String strDate =  String.valueOf(dateForCamparsion );

myRecords =  Database.query ( 'select id ,start_date__c  from MyCustomObject__c
                                                                        where start_date__c ='+strDate );


now  you can check this 

Thank.

No comments:

Post a Comment