We have an email in marketing cloud that has a date of 28 Feb 2019 however this needs to be dynamic based on the following criteria.

When we get to 1 March 2019 the dates year needs to change to 28 Feb 2020

This needs to happen every year on the 1st March. It relates to when a application period closes.

We don't want edit the email each year so was hoping we can use AMPscript to do this however not sure how

Is it possible to do this using AMPScript

1 Answer 1


you could try something like:


  set @today = NOW()

  set @expMonth = '02'
  set @expDay = '28'
  set @expYear = DatePart(@today, 'Y')

  set @expirationRaw = CONCAT(@expMonth, '/',@expDay, '/', @expYear)
  set @expiration = Format(@expirationRaw,"MM/dd/yyyy")

  if datepart(@today, 'M') >= 3  AND datepart(@today, 'D') >= 1 THEN

    SET @expiration = DateAdd(@expiration, 1, 'Y') 


This should make it display the current year by default, but if the date is equal to or beyond 03/01 then it will display next year.

You would just display this by calling the @expiration var. (e.g. %%=v(@expiration)=%%

  • Hi, thanks for this. Tried the code however get the following error: The specified attribute or custom object field name was not found for this client. Function Call: Format(expirationRaw,"MM/dd/yyyy") Attribute or Field Name: expirationRaw
    – Andy
    Commented Nov 28, 2018 at 23:40
  • Oops sorry forgot @ in it. Updating now Commented Nov 29, 2018 at 0:11
  • Hi again, error how now gone however doesnt output anything :(
    – Andy
    Commented Nov 29, 2018 at 0:29
  • 1
    little typo, should be %%=v(@expiration)=%% instead of %%=v(@expiration)%%. Commented Nov 29, 2018 at 7:35
  • Please make sure to mark it as accepted if this resolved your issue to allow for easy reference for others experiencing the same issue. Commented Nov 29, 2018 at 19:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .