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
birdofpreybirdofprey 

Able to do a SOQL on dates only prior to a specific date.

I want to be able query starting 2 weeks ago and prior.

This example

Select Name From Contacts Where CreatedDate <= LAST_N_DAYS:14

This would query me everything from Today() till Today()-14Days.


What I really need is everything that is prior (Today()-14Days).

 

 

 

 

s_k_as_k_a

You can query  

 

example:

 

Select Name from Contacts where day_only(CreatedDate) < = 2012-11-30

 

Below is the  reference Link for some more Date functions that can use in SOQl.

 

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_date_functions.htm

birdofpreybirdofprey
I would work, but I need it to be sort of dynamic like Last_N _Day functions, where it does it relative to today's date. Is my only option is to create a formula field?
s_k_as_k_a

For formula feild you  can select formul result type Date/time

 

and enter the formula 

 

{!Now() -14}

 

 

This gives the 14 days perior to today.

 

I hope it will work. I want to know , Are asking about creating formula  field or using in  soql query?

s_k_as_k_a

For Date/Time  :  {!NOW()-14}

 

For Date  : {!Today() -14}