I'm trying to pull things from the previous month (April only) from a data extension, but am running into something weird. Why wouldn't the initial query of "= DATEADD(month, -1, GETDATE())" produce the result I want? Is there a way around it in Marketing Cloud?
Here are the details
- My two DE's are: StartingDE and EndingDE.
- Columns for both DE's are the same.
Neither are sendable DE's, so I don't have a primary key.
Data for StartingDE is below:
FirstName | LastName | DateOfPurchase Joe | Smith | Friday, May 11, 2018 12:00AM Patty | Page | Tuesday, April 17, 2018 12:00AM Kit | McMaster | Wednesday, March 07, 2018 12:00AM
The below query returns 0 records:
SELECT sd.FirstName, sd.LastName, sd.DateOfPurchase
FROM StartingDE sd
WHERE sd.DateOfPurchase = DATEADD(month, -1, GETDATE())
The below query returns 2 records - Joe Smith (month of May) and Patty Page (month of April):
SELECT sd.FirstName, sd.LastName, sd.DateOfPurchase
FROM StartingDE sd
WHERE sd.DateOfPurchase >= DATEADD(month, -1, GETDATE())