Hi Sara Kidd ,
The DateAdd function can work with negative values. See example below:
var dt = Now();
var fourdaysearlier = DateAdd(dt, -4, "days");
Console(dt);
Console(fourdaysearlier);
return fourdaysearlier;
This will write the following text to the console:
2020-09-09T16:23:42-05:00
2020-09-05T16:23:42-05:00
As you can see you will have a date time of 4 days before. However you will need to use a date range to select records that were taken four days ago.
Have a look at the example below (I assume the sql can be simplified, but I don't have the data to test this):
var dt = Now();
var fourdaysearlier = DateAdd(dt, -4, "days");
var format = "MM/DD/Y";
var fourdaysearliertxt = Text(fourdaysearlier, format);
var sql = "LASTUPDATE BETWEEN timestamp '" + fourdaysearliertxt + " 00:00:00' and date '" + fourdaysearliertxt + " 23:59:59'";
Console(dt);
Console(fourdaysearlier);
Console(fourdaysearliertxt);
Console(sql);