1

I am working with Ampscript and trying to format a date in Exact Target.

I need to pull in the date out of a date/time stamp field. If I use

set @eventStartDay = Format(@eventStartDay,"dd") 

the date pulls in with the leading zero "05".

I changed it to

set @eventStartDay = Format(@eventStartDay,"d"), 

hoping to drop the zero and pull in "5". Instead, the entire date pulls in, formatted like this: "2/5/2015"

What am I doing wrong?

Thanks for any guidance.

0

ET uses the standard C# date formatting library, so "d" will be interpreted to mean "standard short date." (See this). The way around is to use a space, or a percent, which signifies a custom date format string (found at this link). You would do something like:

set @eventStartDay = Format(@eventStartDay, "'{0:%d}'") 

Hope this helps.

| improve this answer | |
  • Thank you! This worked: set @eventStartDay = Format(@eventStartDay, "%d") – Stacey Coleman Nov 11 '14 at 11:58

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.