Quantcast
Channel: Active questions tagged ampscript - Salesforce Stack Exchange
Viewing all articles
Browse latest Browse all 407

Correct date and time while considering Daylight Savings Time (DST) in event confirmations sent out via SFMC but created in SFSC needed

$
0
0

Some time ago I was working on some Marketing Automation improvements at a client when we encountered a very specific problem:

For appointment confirmations sent out via e-mails from SF Marketing Cloud but appointments created in Sales Cloud, we need the correct date and, especially, time while considering Daylight Savings Time (DST).

As SQL and querying in SFMC will give you more than one option to to find the correct date and time, AMPscript doesn’t seem to have those options to integrate that proper date and time in an e-mail.

I have searched Stack and other sources like Mateusz Dabrowski and SalesforceBen, but I couldn’t find the right solution for this specific issue.

The problem is that when creating an appointment/event in Sales Cloud, it shows the correct date and time, also taking DST into account. For example, if you create an event in Central European Time (CET) on February 12, 2024 at 14.00 (2PM) (create date), and the event is at June 14, 2024 at 15.00 (3PM), Sales Cloud will show you those specific dates and times as SC will handle the DST just fine in the front end.The date and time stored in SC is on UTC, so create date will be something like 2024/02/12 13.00.00, as CET is UTC+1 in winter. The event date will be stored as 2024/06/14 13.00.00, as CET is UTC+2 in summer (DST).

The problem with sending out a confirmation with MC, it can take the event date (as stored) and you can add an hour in winter and two hours in summer, but how does the AMPscript determine if DST needs to be applied?

Some consulting parties created a big IF-statement for each year to determine if the event date is in DST and needs 2 hours added, but that means it a manual script and you have to add new dates in there all the time. We especially encountered the problem when the event date was taking place further in the future and the new dates were not added yet, resulting in a confirmation stating the wrong time, in this case June 14, 2024 at 14.00 instead of 15.00. Customers are not really happy with such annoying errors, especially when it’s about real estate.

After googling for ages, I created something based on different scripts. First of all, some recognition to @Gortonington: his site and answers here been of great help. I converted his solution of finding the first specific day in a month to finding the exact dates of any year for the start and end of DST, so that the event date and time can be adjusted accordingly.

Please upvote my question and solution if you encountered the same problem and find this solution useful, so more people can find and use it. And hopefully AMPscript gets updated to simply adjust for DST a bit easier that this solution.


Viewing all articles
Browse latest Browse all 407

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>