I have a triggered email which is supposed to show a date which is 30 days from the date the email is received.

E.g. John Smith clicks something on a website and receives a triggered email today, June 25th and in his email he is encouraged to take an action by July 23rd (30 days from the moment he received the email). In this case, I need July 23rd, 2015 to appear dynamically in the email.

How can I add this sort of dynamic date into an email through AMPscript? Is there a function or something that calculates this and spits out the date?


Calculating the future date is fine, but it's not static. The AMPScript will get re-evaluated in certain scenarios -- like in the View As a Web Page page.

I would create a future date variable using the format() and dateadd() functions as suggested, but I would also retrieve it from the Triggered Send Data Extension or the SendLog, depending on the email context.

Something like this:

var @futureDate, @rs, @rows, @row, @futureDateFromDE

if _messageContext == "SEND" then
  set @futureDate = Format(DateAdd(Now(), "14", "D"), "MMMM dd")
  /* retrieve date value from appropriate data extension using a lookup function */
  set @futureDate = @futureDateFromDE

Your trigger's target Data Extension or SendLog would need to have a futureDate column.

Reference: AMPScript Lookup Examples

  • thanks guys, so that means I have to have the date, the triggered email is sent, captured in a lookup DE? – Snowalker Jun 26 '15 at 12:44
  • You certainly don't have to, but I would. The capturing part is automatic as long as you have the futureDate column included in the DE defined in your Triggered Send Definition or the SendLog. – Adam Spriggs Jun 26 '15 at 12:57
  • I have no idea how to capture the send date into a DE :( wouldn't be easier to just use the present time at the moment the user opens the email? – Snowalker Jun 26 '15 at 12:59
  • Sure. My point was that it's not static -- it'll change if they click through to the VAWP. If the VAWP isn't important, then just go with the format() and dateadd() – Adam Spriggs Jun 26 '15 at 13:01
  • umm I will have to play a bit with format() / dateadd() and see if it does what I need. I'm wondering if the current date will be the one when I deploy the email or the one when the user opens - the user may open it multiple times and then we will end up with 30 days added every time they open... – Snowalker Jun 26 '15 at 13:31


You can use the DateAdd() function for that.

Here is the function with formatting:

%%=Format(DateAdd(@today, "14", "D"), "MMMM dd")=%%

%%=DateAdd([insert date or variable here], "number to add", "Unit of time")=%%

Just a note this will be calculated based on the date sent, so if you send june 25 and the recipient does not open for 10 days, the date will still read July 23.

Hope this helps


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.