Unfortunately, all of the AMPScript lookup functions use only AND conditions with =
operators, which means, you can't use criteria like insertDate > DateAdd(now(1), -2, "H")
Theoretically, if your triggered send data extension included a column that you could match exactly (with an =
operator) then you could do it.
To do that you'd need to add an insertDateStr
column to your TSD DE and then include this code in your email AMPscript.
%%[
var @insertDateStr
set @intertDateStr = formatDate(now(1),"YYYYMMddhh"))
]%%
Then your exclusion script could be something like this:
Rowcount(LookupRows("Data Extension Name", "EmailAddress", emailaddr, "insertDateStr", formatDate(now(1),"YYYYMMddhh"))) > 1
OR Rowcount(LookupRows("Data Extension Name", "EmailAddress", emailaddr, "insertDateStr", formatDate(DateAdd(now(1), -1, "H"),"YYYYMMddhh"))) > 0
First one catches anyone in the current hour. Rows are written to the DE first and then the email is sent, which is why it needs to be > 1
.
The second one catches any rows for the previous hour.
To test this before updating your Triggered Send Definition, you could add the exclusion script code to the email code and output the results, then review it against rows that qualify (or not).
Let us know how it goes! This is an interesting scenario.
Update
To test in the email code you can do something like this:
%%[
var @insertDateStr
set @intertDateStr = formatDate(now(1),"YYYYMMddhh"))
var @rc1, @rc2
set @rc1 = Rowcount(LookupRows("Data Extension Name", "EmailAddress", emailaddr, "insertDateStr", formatDate(now(1),"YYYYMMddhh")))
set @rc2 = Rowcount(LookupRows("Data Extension Name", "EmailAddress", emailaddr, "insertDateStr", formatDate(DateAdd(now(1), -1, "H"),"YYYYMMddhh")))
output(concat("<br>insertDateStr: ", @insertDateStr)
output(concat("<br>rc1: ", @rc1)
output(concat("<br>rc2: ", @rc2)
]%%
NOTE: Be sure that the LookupRow functions are retrieving from the data extensions configured in your triggered send definition.