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]%%
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communitydo 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]%%
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.
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)=%%