Does LAST_N_DAYS:1 Include TODAY?

I would like to ask about the definition of LAST_N_DAYS:n

For the number n provided, starts 00:00:00 of the current day and
continues for the past n days.

Is

CreatedDate = LAST_N_DAYS:1

equal to

(CreatedDate >= 2017-08-30T00:00:00Z AND CreatedDate <= 2017-08-30T23:59:59Z)
OR CreatedDate  = TODAY

and

CreatedDate >= YESTERDAY

To be more specific, isn’t LAST_N_DAYS in fact LAST_N_DAYS + 1 (Today)?

Answer

In contradiction to what the current documentation claims, you can observe that the LAST_N_DAYS date literal includes today’s data.

To be sure, I ran this query:

SELECT CreatedDate FROM MyObject__c
WHERE CreatedDate = LAST_N_DAYS:1
ORDER BY CreatedDate DESC LIMIT 1

And I got back:

2017-08-31T18:16:17.000+0000

Attribution
Source : Link , Question Author : Pawel Gumiela , Answer Author : Adrian Larson

Leave a Comment