If you ever need to truncate a decimal value instead of rounding it, give this a try:
Code
Output
num1: 12.99
num1_rounded: 13
num1_formatted: 12
Try it yourself: https://mcsnippets.herokuapp.com/s/gQhFesBi
the personal blog of adam spriggs
Scenarios and code samples for scripting in Salesforce Marketing Cloud with AMPScript.
If you ever need to truncate a decimal value instead of rounding it, give this a try:
num1: 12.99
num1_rounded: 13
num1_formatted: 12
Try it yourself: https://mcsnippets.herokuapp.com/s/gQhFesBi
Here’s an AMPscript snippet to determine if a date falls in the Daylight Savings period as defined by NIST.gov:
Output:
dateToCheck: 2023-10-25
month: 10
day: 25
dayOfWeekToFind: Wed
dayOfWeekNum: 4
prevSunday:
isDST: 1
Try it yourself with multiple dates: https://mcsnippets.herokuapp.com/s/KcEDbfxA
NOTE: this doesn’t handle times, but could be expanded to do so.
With additional scrutiny on outbound links in corporate inboxes these days, one-click unsubscribe pages aren’t always a good idea — any visit from a click will result in an immediate action. In the case of a one-click unsubscribe page, it’s an opt-out.ย That’s no good.
Here’s an example of a two-click unsubscribe page that requires an additional click to confirm the subscriber’s desire to unsubscribe (or not).
As always, if you have any feedback, questions or find any issues with this, feel free to drop me note on the contact page or via comment down below.
It’s been a few months since the judging wrapped up for the Baby Shark AMPscript Challenge on HowToSFMC. The goal was to use AMPscript to output the lyrics of Baby Shark (EARWORM WARNING). There were a few of categories for submissions, but I read them all as “with as little code as possible”. Obstinate fixation… engage!
To be completely honest, I spent way too much time obsessing over my own solution — enjoying every moment. Shortest I got on my own was 260 characters. Here are my 7 variations:
Here’s a brief video covering a little trick I use to format HTML in preparation for use in Salesforce Marketing Cloud. These are the patterns:
To enable the regular expression option in the search bar, click this button (or use Alt-R):
Links: