Sunday, October 16, 2011

How to query using date time field in Salesforce

There are many instances where we need to query on base of createddate or any other datetime field to find some specific records for particular day or for that month or for that year etc.

We cannot directly query with datetime field in where condition.

So you will need to use Date functions in SOQL to query using datetime field in where condition

Example:
 Opportunity =[SELECT Id, Name FROM Opportunity WHERE DAY_ONLY(CreatedDate)= '2011-10-16'];  


Refer other date functions which are available so that you can query easily using datefield in where condition.
Date functions

8 comments:

jaya said...

While trying with that Query it shows error.

we have to write that Query like this

Opportunity =[SELECT Id, Name FROM Opportunity WHERE DAY_ONLY(CreatedDate)= 2011-10-16];

Jeffy said...

Superb i really enjoyed very much with this article here. Really its a amazing article i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.

Digital Marketing Company in Chennnai

Sathya G said...

Thank you for sharing such a nice and interesting blog with us. i have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle. please keep on updates. hope it might be much useful for us. keep on updating...
Android training in chennai

Sathya G said...

Superb. Really enjoyed very much with this article here. Really its a amazing article i had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your updation.
Android training in chennai

Shalini said...

Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
Digital Marketing Company in India
seo Company in India

vinu priya said...

your information is really awesome as well as it is very excellent and i got more interesting information from your blog. Android App Development Company in Chennai

Sanjana sekar said...

Wonderful blog.. Thanks for sharing informative blog.. its very useful to me.. Security Mobile alerts Chennai

Evangeline Mitul said...

Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting. So know it's helpful..

Dental Hospital In Chennai