function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Software EngineSoftware Engine 

Problem with DateTime in Query

Hi,
 
I have a custom field which type is datetime.  But i should query only on  date part.
Is it possible?  If not possible i am giving a try to query with full datetime.
 
By default datetime value stores as in the Greenwich Mean Time (GMT) or Coordinated Universal Time (UTC) time zone. We have to covert the datetime  field value to  local time format when we querying.
 
What is the salesforce time format. Is it following GMT or UTC. Basing on the time format following by salesforce how much time do i need to add or subtract  from the stored field value.
 
 
Ex: Actually my custom field date time stored as 5/21/2007 9:30 AM
 
Query:  select EnteredDate__c from opportunity where EnteredDate__c = 2007-05-21T14:30// giving error
 
Thanks,
DevAngelDevAngel
You will need to add a time zone offset to the ISO 8601 format.

2007-05-05T12:34:23-08:00

for example.
Software EngineSoftware Engine

HI,

    As you said If i add the offset to datetime field value it is not identifying the records.  I am getting the  message as " No Records Matched Query ". But no errors.

    If i do not add the offset to the field,  i am getting the error as " Malformed Query ".

  Actually when i query the field without where condition i am getting the output as follows.

        Q: Select EnteredDate__c from opportunity    

        Ouput:    5/21/2007 9:20 AM

  But when i query with the where condition by adding offset to the value, no records matching with the value.

Q: Select EnteredDate__c from opportunity where EnteredDate__c=2007-05-21T09:20:00-08:00 

   //No Records Matched Query.

How to fetch the records?

Thanks & Regards,

     Arjun.

 

 

 

 

 

SuperfellSuperfell
What you don't show is, what TZ is that 9:20 am in? is it GMT, your local TZ (which if you're in pacific time, is currently -07:00 i believe, not -08:00) You need to apply the correct TZ indicator.