AnsweredAssumed Answered

Email scripts: using dates

Question asked by 400a4f0782eb3328af3a4b79643916824d80e02c on Jan 10, 2017
Latest reply on Jan 11, 2017 by 400a4f0782eb3328af3a4b79643916824d80e02c

Hi everyone

 

Having a bit of trouble formatting dates through email scripting.

 

Here's my initial code:

 

<ul>

#foreach ($Tour_Details in ${TravellerServices__cList})

    #if (${Tour_Details.Service_Status__c} == "Confirmed" && ${Tour_Details.ServiceTypeTS__c} == "Tour")

  <li>You took ${Tour_Details.Service_Dossier_Name__c} on ${Tour_Details.Service_Start_Date__c}).

  </li>

    #end

#end

</ul>

 

This gives me this:

 

  • You took ATTW on 2013-03-16.
  • You took PAA on 2014-06-30.

 

Good so far!

 

Next I tried to format the dates to say "16 March 2013" instead of the current format. So I tried:

 

#foreach ($Tour_Details in ${TravellerServices__cList})

    #if (${Tour_Details.Service_Status__c} == "Confirmed" && ${Tour_Details.ServiceTypeTS__c} == "Tour")

  <li>You took ${Tour_Details.Service_Dossier_Name__c} on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).

  </li>

    #end

#end

</ul>

 

But this gives me:

 

  • You took ATTW on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).
  • You took PAA on $date.format('dd mmm yyyy' ,${Tour_Details.Service_Start_Date__c}).

 

Something is obviously wrong. Any ideas?

 

As a side note, while playing around I tried to use Marketo's example, found here: http://developers.marketo.com/email-scripting/

http://developers.marketo.com/email-scripting/

 

#set($birthday2015 = "2015-08-07")

##use whenIs to determine how many days away it is

$date.whenIs($birthday).days ##outputs 1

 

This doesn't seem to work. The output is:

 

$date.whenIs($birthday).days

 

It didn't work even when I renamed the variable from $birthday to $birthday2015 in the last line, which I thought might be the error.

 

Is there something I need to do to "load" the $date functionality in scripting?

 

Thanks, Phil

 

$date.whenIs($birthday).days ##outputs 1

 

Outcomes