0

I was trying to concat a date in a URL with a specific format, but I need to add 1 day to the date that already exist in data extension.

VAR @sd, @formatSd, @date_plus1

set @sd = AttributeValue("fecha_salida")

set @formatSd = FormatDate(@sd, "dd/MM/yy")

at this point the script works, but when I try to use the function DateAdd like this it is not working:

set @date_plus1 = Format(DateAdd(@sd, "1", "D"), "dd/MM/yy")

What I'm doing wrong? I'm working in cloudpages

2

Try to do it in a different order, like in the example below - first the DateAdd, then Format:

%%[ 
VAR @futureDate, @today 
SET @today = Now(1) 
SET @futureDate = DateAdd(@today, 11, "D") 
]%%
Date: %%=Format(@futureDate, "MMMM d, yyyy")=%%

Your updated script should also work, so check if the date field is set to 'Date' data type in your Data Extension:

%%[
set @sd = AttributeValue('Date')
set @date_plus1 = Format(DateAdd(@sd, "1", "D"), "dd/MM/yy")
]%%

@sd: %%=v(@sd)=%%
<br>
@date_plus1: %%=v(@date_plus1)=%%
<br>

It resolves to:

@sd: 8/21/2019 12:00:00 AM
@date_plus1: 22/08/19

| improve this answer | |
  • Thank you @CodeRage. I am trying with this and take me to an error 500, but when I use “Now” value, it works code set @date_plus1 = Format(DateAdd(Now(true), "1", "D"), "dd/MM/yy") code I also need to concat data in an URL, I’m trying with set @link = Concat(@url,@date_plus1,@utm) I have already checked the field type and it is correct. Before I was using FormatDate with no problem to achieve the correct format for the URL, set @formatSd = FormatDate(@sd, "dd/MM/yy") but now I need to add 1 day to that date – Fernando Aug 21 '19 at 17:14
  • Most likely you get the 500 because you’re not passing a paremeter correctly. You need to test against a subscriber, and if you are querying “fecha_salida” it needs to be passed correctly to the CloudPage. – zuzannamj Aug 21 '19 at 17:17
  • Thanks, I've test an email with subscriber data an it works – Fernando Aug 21 '19 at 17:29

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.