0

While setting an hour in Sales, it seems the Amscript in Marketing Cloud I am using is getting minus one hour. I set 14.00 in Sales and I get 13:00 in Marketing Cloud.

I am trying to use zzz or xxx but I don´t know how to remove the difference.

%%=FormatDate(@FechaCita, "","HH:mm:zzz", "es-ES")=%%

How can I get the right time?

1
  • To verify, you are saying that when you format the date, the time it is returning is 1 hour less than what you have in your original? FormatDate() should not cause any changes to the data you provide except for the way it is displayed. I would verify that the transition from SalesCloud to Marketing Cloud does not cause the change - as that is more likely the suspect for the change in displayed time. Dec 18, 2018 at 14:10

5 Answers 5

2

To format a date and return it in the specified format,

%%=Format("2017-10-05 13:21:34.567890", "MMM dd, yyyy", "HH:mm:ss.tt", "en-US")=%%
1

It's not an issue with formating, it's time-zone difference- Sales Cloud returns data in GMT, you are GMT+1.

Are you retrieving your date with Ampscript RetrieveSalesforceObjects() or from a data extension? If you use RetrieveSalesforceObjects, it containes timezone info as well, so you can just wrap your date in SystemDateToLocalDate to return it in your user selected timezone.

%%=SystemDateToLocalDate(@FechaCita)=%%

If you get data from data extension you can just simply add one hour with DateAdd() but it might produce incorrect results sometimes (depending on summer/winter time changes):

%%=DateAdd(@FechaCita, '1','H')=%%
2
  • I used the second option from @Mateusz and it worked smooths. thanks a lot!
    – Daniel
    Dec 18, 2018 at 16:02
  • the end formula was:
    – Daniel
    Dec 18, 2018 at 16:03
1

the final formula:

%%[set @FechaCita = DateAdd(Lead:Date_first_visit__c, '1','H')]%%

%%=FormatDate(@FechaCita, "DD", "", "es-ES")=%% 
de %%=FormatDate(@FechaCita, "MMMMM","", "es-ES")=%% %%=FormatDate(@FechaCita, "","HH:mm", "es-ES")=%%  %%Lead:Centro_primera_visita__r:Name%%.
0

You can split the date elements and then add one hour like this:

SET @HH = FormatDate(NOW(), "","HH", "es-ES")
SET @mm = FormatDate(NOW(), "","mm", "es-ES")
SET @zzz = FormatDate(NOW(), "","zzz", "es-ES")
SET @HH_fixed = Add(@HH, "1")

And you can show it like that:

%%=v(@HH_fixed)=%%%%=v(":")=%%%%=v(@mm)=%%%%=v(":")=%%%%=v(@zzz)=%%
0

You can also find here the AMPscript Date and Time Formatting. It may help you.

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.