+ Start a Discussion
kminevkminev 

Date comparison in Flex to SF Api integration

Hi,

 

I have custom object with field of date type (not datetime/timestamp) and I need to query from my Flex/AS3 code for date range  (WHERE date => myDtObject)

 

What should be the format I need to pass my date object to salesforce in order to perform date comparison???

 

This is my code:

 

private function getTimesheetRecordsByWeek(dtStart:String, dtEnd:String, userName:String):void{
                               
                var strQuery:String = "SELECT t.Activity__c, t.ActivityType__c, t.Billable__c, t.Client__r.Name, t.WeekStartDate__c, t.WeekEndDate__c, " +
                                      "t.MondayHrs__c, t.TuesdayHrs__c, t.WednesdayHrs__c, t.ThursdayHrs__c, t.FridayHrs__c, t.SaturdayHrs__c, t.SundayHrs__c, t.WeeklyHrs__c " + 
                                      "FROM Timesheet__c t " +
                                      "WHERE t.WeekStartDate__c => " + "2009-05-25" + " and t.WeekEndDate__c =< " + "2009-05-28" + " and t.Owner.Name = '" + userName + "'";
                                      //"WHERE t.WeekStartDate__c >= " + DateUtil.dateToIso(new Date(dtStart)) + " and t.WeekEndDate__c <= " + DateUtil.dateToIso(new Date(dtEnd)) + " and t.Owner.Name = '" + userName + "'";
               
                apex.queryAll(strQuery, new AsyncResponder(onTimesheetsResult, onQueryFault));

            }

 

 

Thank you very much in advance.

 

 

Best Answer chosen by Admin (Salesforce Developers) 
DevAngelDevAngel

You will need to use the ISO8609 date format (YYYY-MM-DDThh:mm:ssz) for your SOQL query.

 

See the documentation here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_dateformats.htm

 

Cheers