Search
Twitter
« Cloudingo Promo Code | Main | Unable to fetch and save Force.com... »
Wednesday
Mar202013

SOQL Date Formats

Coming from an SQL background, I’ve always had issues with SOQL’s date format. So, today, I’m going to share with you some tips on how to utilize SOQL Date queries, specifically using Built in Date Functions:

Before we dig in too deep though, we must know the syntax for Date in Force.com:

YYYY-MM-DD

 

In Force.com, there are two ways of querying Date:

#1 Specify the date in the query

The following query will return all Id’s for all the leads that were created on 2012-12-12 : Select ID, Date from Lead where Date= dateValue (2012-12-12)


#2 Query with a Built in Function

For example, the following query will return all Id’s for the Lead that were created yesterday: Select Id, Date from Lead where Date= YESTERDAY

I hope this helps!

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.