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

13 comments:

Anonymous 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];

Unknown 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

Unknown 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

sakthi said...

I found your blog while searching for the updates, I am happy to be here. Very useful content and also easily understandable providing.. Believe me I did wrote an post about tutorials for beginners with reference of your blog. 

rpa training in chennai
rpa training in bangalore
rpa course in bangalore
best rpa training in bangalore
rpa online training

ram said...

I found this informative and interesting blog so i think so its very useful and knowledge able.I would like to thank you for the efforts you have made in writing this article.
Data Science Training in Indira nagar
Data Science training in marathahalli
Data Science Interview questions and answers
Data Science training in btm layout | Data Science Training in Bangalore
Data Science Training in BTM Layout | Data Science training in Bangalore
Data science training in kalyan nagar

Julia Loi said...


I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article.

mobile phone repair in Memphis
iphone repair in Memphis
cell phone repair in Memphis
phone repair in Memphis
tablet repair in Memphis
ipad repair in Memphis
mobile phone repair Memphis
iphone repair Memphis
cell phone repair Memphis
phone repair Memphis

Julia Loi said...



mobile phone repair in Auburn Hills
iphone repair in Auburn Hills
cell phone repair in Auburn Hills
tablet repair in Auburn Hills
ipad repair in Auburn Hills
mobile phone repair Auburn Hills
iphone repair Auburn Hills
cell phone repair Auburn Hills
phone repair Auburn Hills
tablet repair Auburn Hills

cheap hidden cameras
ismartalarm camera
dymo label maker
Waterproof Action Camera
Coleman full size air mattress
womens cotton long johns
APPLE WATCH SERIES 3 INFORMATION
Winter Cycling Jackets For Men

pratheep said...

Really it was an awesome article about JAVA, very interesting to read.You have provided an nice article,Thanks for sharing.
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

nisha said...

The Blog is really nice. every concepts are clarify the queries for the learners.#

Data Science Training Course In Chennai | Data Science Training Course In Anna Nagar | Data Science Training Course In OMR | Data Science Training Course In Porur | Data Science Training Course In Tambaram | Data Science Training Course In Velachery

Jayalakshmi said...

Awesome post, you got the best interview questions and answers for Oracle interview. You’re doing a great job.
angular js training in chennai

angular js training in tambaram

full stack training in chennai

full stack training in tambaram

php training in chennai

php training in tambaram

photoshop training in chennai

photoshop training in tambaram

jeni said...

I just recently discovered your blog and have now scrolled through the entire thing several times. I am very impressed and inspired by your skill and creativity, and your "style" is very much in line with mine. I hope you keep blogging and sharing your design idea
hardware and networking training in chennai

hardware and networking training in velachery

xamarin training in chennai

xamarin training in velachery

ios training in chennai

ios training in velachery

iot training in chennai

iot training in velachery

shiny said...

Excellent and very cool idea and the subject at the top of magnificence and I am happy to this post.



data science training in chennai

data science training in annanagar

android training in chennai

android training in annanagar

devops training in chennai

devops training in annanagar

artificial intelligence training in chennai

artificial intelligence training in annanagar

deiva said...

It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.
sap training in chennai

sap training in omr

azure training in chennai

azure training in omr

cyber security course in chennai

cyber security course in omr

ethical hacking course in chennai

ethical hacking course in omr