0

Background: On a cloud page in SFMC, I am trying to display a message if today's date is between start and end dates that are coming from data extension.

Question: How can I perform a check and see if today's date is between start and end dates?

Issue: Nothing is currently displaying on the cloud page.

Here is what I got so far on a cloud page:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
    </head>
    <body>

        %%[
        set @date = Now()
        set @searchterm = "true" /* value from attribute or DE column in send context */
        set @getStart = Lookup("Test_DE_Dates", "Start_Date", "ROW_ADDED", @searchterm)
        set @getEnd = Lookup("Test_DE_Dates", "End_Date", "ROW_ADDED", @searchterm)
        
        IF  @date >= @getStart AND @date <= @getEnd THEN 
            set @output= 'true'
        ]%%          
                    
            <div class="sectionForm">
            <div class="columns col1">
            <div data-type="slot" data-key="col1"></div>
            </div>
            </div>
                
        %%[ ELSE ]%% 

            %%[ set @output = 'false' ]%%
            <p>This page has been expired</p>

        %%[ ENDIF ]%% 

    </body>
</html>
4
  • 1
    Not sure if it's a copy-paste error, but there's a premature closing block delimiter (]%%) after the @getStart variable is set. Try removing that first.
    – Mark G
    Commented Aug 31, 2023 at 23:02
  • Thank you @MarkG for the call out, yes that was a mistake in pasting the code here. If you have any feedback on the logic, I am happy to hear and learn :)
    – kl2
    Commented Aug 31, 2023 at 23:17
  • 1
    Your logic seems okay. What do you mean by "nothing" is displaying on the page? It's completely blank? Not even a false for @output? If you inspect the page's generated HTML from your browser (via dev tools), is it empty? Try a pure AMPscript implementation first (without the HTML) and make sure the values for @getStart and @getEnd are what you expect them to be.
    – Mark G
    Commented Aug 31, 2023 at 23:41
  • Hi @MarkG I ended up fixing it myself, there was an issue with the AMPScript. I have posted the WORKING / updated code above in my question. I am here to learn so if there is any issue with this approach or anything that can be imported, I am open to feedback :)
    – kl2
    Commented Aug 31, 2023 at 23:55

0

You must log in to answer this question.