0

I am running the following query in my account to get all subscribers that have a departure date in 3 days:

SELECT SubscriberKey

FROM [Trip]
WHERE Date_of_Departure = DATEADD(day, +3, GETDATE())

However, the query returns 0 records, although a Data Filter with the same logic returns 27 records. What would I need to change in this query so that it can run using Automation Studio on a daily basis and always appends the users that have a departure date in today +3?

1

You'll need to handle the time portions of the dates in SFMC Query Activities.

Casting the date column as a date will set the time to 00:00.

SELECT SubscriberKey
FROM [Trip]
WHERE Date_of_Departure >= DATEADD(day, 3, cast(GETDATE() as date))
and Date_of_Departure < DATEADD(day, 4, cast(GETDATE() as date))

Or less efficiently:

SELECT SubscriberKey
FROM [Trip]
WHERE cast(Date_of_Departure as date) = DATEADD(day, 3, cast(GETDATE() as date))
| improve this answer | |
-1

In a SOQL query you can specify either a particular date or a date literal. A date literal is a fixed expression that represents a relative range of time, such as last month, this week, or next year.

NEXT_N_DAYS:n

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

Example:

    List<Opportunity> oppList = [SELECT Id FROM Opportunity WHERE CloseDate = NEXT_N_DAYS:3];
System.debug('###'+oppList);

Reference Salesforce Document

| improve this answer | |
  • This is not a Sales Cloud question. – Adam Spriggs Jun 24 '16 at 11:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.