this might be helpful for some, but I also feel like it might be able to be improved upon or simplified. I have a recurring email campaign once a month that offers a new promotion for the course of the month. I didn't want to continuously update it so I wrote some code to handle it. The only issue is that every four years we have a leap year and not all months have the same amount of days. So this is what I've got in the AMPScript:
%%[ SET @monthOf = Format(now(),"MMMM") SET @monthNumber = Format(now(),"MM") SET @yearOf = FormatDate(now(),"YYYY") SET @monthEndDate = "" IF @monthNumber == 01 OR @monthNumber == 03 OR @monthNumber == 05 OR @monthNumber == 07 OR @monthNumber == 08 OR @monthNumber == 10 OR @monthNumber == 12 THEN SET @monthEndDate = 31 ELSEIF @monthNumber == 02 AND @yearOf == 2020 THEN SET @monthEndDate = 29 ELSEIF @monthNumber == 02 AND @yearOf != 2020 THEN SET @monthEndDate = 28 ELSE SET @monthEndDate = 30 ENDIF ]%%
I then call this later within the email text that states the start date and end date of the month.
Offer valid %%=v(@monthNumber)=%%/01 - %%=v(@monthNumber)=%%/%%=v(@monthEndDate)=%%.
This is the date format that is requested of me, so I cannot modify the way the date is displayed. If this is the best way to achieve this, great, but if there is a way to modify this to be better I'd be interested in learning it. If this helps someone else as well, excellent! Thanks!