You need to sign in to do that
Don't have an account?
Records Created Last Year, This Month
Hi,
I need to get all those records which were created in 'This month of Last Year'. Since this is November 2012, I need to get all the records created in November last year in SOQL query. I run this query on the 1st of every month. Is there any exact date literal ? Can I compare the months or something like that ?
I have checked Data Literals, I found LAST_N_DAYS:n . I used it to build the following query ( which I do not like it)
SELECT Id FROM Account WHERE CreatedDate <= LAST_N_DAYS:365 && CreatedDate >= LAST_N_DAYS:335
(365-335 =30 days difference, 1 month difference)
The query gives incorrect results and is not perfect as the query picks 30 days difference every month which is wrong. If I go with this, I need to calculate for 31 days as well and have to consider leap years and all which is hectic.
Any simple Ideas please?
All Answers
Thanks Scott. That works :)