0

I looking for a way to remove the time stamp of a date field when using personalization strings. I got this format when using PS: 3/1/2020 12:00:00 AM. I want to remove that part "12:00:00 AM". Here is my personalization strings for the date field: %%=lookup('CONTRATS_HABITATION','DATE_EFFET_CONTRAT','CONTACT_ACCOUNT_ID',CONTACT_ACCOUNT_ID)=%%

I have read in another post that I could use that function FormatDate(Now(), "MMM dd, yyyy") by replacing the Now() by my date field. But I don't know how to proceed. Does anyone have some insights about this?

Thanks!

UPDATE I just wanted to add a solution to my last comment. Since the field is contained in a non-sendable data extension, I had to find a way to retrieve it and to truncate the date field. Here is my solution: %%=v(FormatDate(lookup('CONTRATS_HABITATION','DATE_EFFET_CONTRAT','CONTACT_ACCOUNT_ID',CONTACT_ACCOUNT_ID), "dd MMMM yyyy",,"fr-CA"))=%%

1 Answer 1

1

That's right, you can use the FormatDate function to truncate the time part from your datetime.

In your case, it would be something like:

Set @DATE_EFFET_CONTRAT_TRUNC = FormatDate(DATE_EFFET_CONTRAT, "MMM dd, yyyy")

The output would be:

Mar 01, 2020

In this case, I assume your personalization string is DATE_EFFET_CONTRAT

Also, I see that you are using french language. So just in case you need to format your date using the french format, you can try something like:

Set @DATE_EFFET_CONTRAT_TRUNC = FormatDate(DATE_EFFET_CONTRAT, "dd MMMM yyyy",,"fr-CA")

The output would be:

01 mars 2020

If you want to use only this date in your subject line, you can try:

%%=v(FormatDate(DATE_EFFET_CONTRAT, "dd MMMM yyyy",,"fr-CA"))=%%

Otherwise, you need to use create a @subjectLine variable, and concatenate all your content to it on the email content and put in your subjectline textfield: %%=v(@subjectLine)=%%

Reference:

Checkout this FormatDate page for more options..

6
  • Hi @Rachid Mamai, thanks for the very quick reply. Should I just copy paste that code in my subject line for example? Feb 6, 2020 at 16:25
  • It depends on your use case.. Feb 6, 2020 at 16:41
  • In the subject line I just want to show the value for "DATE_EFFET_CONTRAT" according to subscribers' data Feb 6, 2020 at 16:43
  • 1
    @GrégoireSarrola I've updated my answer accordingly Feb 6, 2020 at 16:49
  • Thanks a lot @Rachid Mamai! The data doesn't show up because my field is contained in another data extension (linked via data relationship and in data designer). I will dig into that issue. Feb 6, 2020 at 16:54

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.