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
lapaullapaul 

Function to determine the age of a particular date

Hi,

Is there any handy function that allows me to determine the age (ie: number of days) of a particular

date? I would like to use this kind of function for my SQSL statement to pull the records that

are 7 days old or less based on the publication date field. Please advice.

 

thanks

Paul

 

gm_sfdc_powerdegm_sfdc_powerde

You might want to use last_n_days date literal like this - 

> WHERE PublicationDate = LAST_N_DAYS:7

lapaullapaul

Thanks for your reply. I tried the following SOQL statement and it gave me an error message that says

"unexpected token: LAST_N_DAYS". Please advice.

 

Select Id, Title, CreatedDate From ContentVersion where CreatedDate = LAST_N_DAYS:7

 

Rajesh ShahRajesh Shah

Following is the syntax

 

SELECT Id FROM Account WHERE CreatedDate = LAST_90_DAYS

 

 For more details, check the following link.

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

 

lapaullapaul

This SOQL statement actually works. thanks so much.

 

Select Id, Title, CreatedDate From ContentVersion where CreatedDate = LAST_N_DAYS:7