1

How can I make the 30 days from now date appear in the body of the email when viewed online?

I can do that easily with AMPscript for the non-online version (NOW()+30) but the online version will recalculate the date every time is opened. How can I make it not change?

I don't have access to the data file to insert an additional field for the deployment date.

1

3 Answers 3

4

As per your situation, the view online re-executes the AMPScript that's why @today picks up the current date. I had a similar situation and here is my solution. Although notice this method would have few seconds difference compared to the @today in your non-online version.

Having (true) within the Now() function falls back to the original time when the email was sent/previewed and if you use the @today within your online version it will use the original time of the sent/previewed.

%%[
SET @today = SystemDateToLocalDate(Now(true))

IF _messageContext == "VAWP" THEN
    /* Set the time to be 30 days from original send time */
    SET @newTime = FormatDate(DateAdd(@today,30,'D'),'DD/MM/YYYY')
ENDIF
]%%
3
  • sorry for getting this late to your solution Brad. For whatever reason SystemDateToLocalDate(Now(true)) works just fine in the view online email but it won't show correctly in the inbox. Date of sent shows the system time at the time of open in the inbox. I wanted to share the code but the character limit doesn't allow it even if it's just a couple of lines of code...
    – Snowalker
    Commented Nov 21, 2017 at 16:08
  • hmm I just removed the VAMP condition and it works just the same in the online email (SET @timeofsent = SystemDateToLocalDate(Now(true))). Same issue in inbox no matter what I do, the deployment time shows as the email received time, so both dates and times are identical. I used Now(true) and Now(1) with the same results.
    – Snowalker
    Commented Nov 21, 2017 at 16:45
  • try using this format to remove the system time from your date string. I hope this helps man. Good luck. %%=Format(SystemDateToLocalDate(DateAdd(Now(true), "30", "D")), "MM/dd/yyyy")=%% Commented Feb 8, 2018 at 20:50
0

try using this format to remove the system time from your date string. I hope this helps man. Good luck.

%%=Format(SystemDateToLocalDate(DateAdd(Now(true), "30", "D")), "MM/dd/yyyy")=%%
0

Here's what works for me:

1) Identify a subscriber and get the job id of a sent:

SET @subscriberKey = _SubscriberKey

SET @jobId = jobid

2) Get the date of a sent from _Sent Data View:

SET @sentDate = Lookup('_Sent', 'EventDate', 'SubscriberKey', @subscriber_key)

3) Check a difference between today and @sentDate:

DateDiff(NOW(), @sentDate, 'H')

So for example:

%%[ 

IF DateDiff(@sentDate, NOW(), 'H') > 24 THEN 

   SET @message = 'X' 

ELSE

    SET @message = 'Y'

ENDIF 

]%%

You must log in to answer this question.

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