0

do you know how to identify an empty date field.

When I'm doing if not empty I'm still receiving default date value if it's empty. How to get rid of it?

%%[IF NOT EMPTY(@RegistrationDate) THEN]%%

 %%=v(@RegistrationDate)=%%

%%[ENDIF]%%
2
  • Is see in tags you search to do this in ampscript, i suggest you to put this information in title or in body !
    – arnaud
    Mar 16 at 8:28
  • arnaud it's not about the place. It is in the body.
    – Natalia
    Mar 16 at 9:27

2 Answers 2

-3

You need to call ENDIF inside the ampscript block and needs to set some value after THEN condition. Try like this

%%[ IF NOT EMPTY(@RegistrationDate) THEN set @RegistrationDate=AttributeValue("RegistrationDate") else set @RegistrationDate_new=AttributeValue("RegistrationDate") ENDIF ]%%

%%=v(@RegistrationDate_new)=%%

This code will display the RegistrationDate wherever present and will show blank if not available.

3
  • thanks, but I don't want to show any date if the field is empty.
    – Natalia
    Mar 16 at 9:56
  • @Natalia - did this really solve your issue? Mar 16 at 11:28
  • @Dalesha I changed it a bit but in general it works as it should so thanks a lot!
    – Natalia
    Mar 16 at 13:28
1

You write, that you see the default date in the Ampscript code. Ampscript would never show a default date, if the data extension field and/or the variable is indeed empty. You don't write where or how you populate @RegistrationDate, so it is difficult for me to advice on how to solve this, but I suspect the data extension field is set to use a default value if a records is created without the date being set.

Additionally, there is a more efficient notation in Ampscript to do what you want to achieve - using IIF function:

%%=IIF(EMPTY(@RegistrationDate),'',@RegistrationDate)=%%
1
  • thanks a lot, but this solution wasn't working for me. I didn't have default value in Data Extension for this field so actually I don't know why it was displaying in email when the value in DE was empty. Nevertheless solution with AttributeValue helped.
    – Natalia
    Mar 16 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .