How do I apply a date format to a question ID?


example 1: [question(“value”), id=”29″,format=”Y-m-d”]

example 2: [system(“date”),format=”Y-m-d”]


I can’t figure out the syntax to make example 1 work. Example 2 works without a problem!

Alex Walker answered

    You will have to write a custom script.

    The problem is that the data returned by the question’s merge code is actually text data and not date.  So in order to format it you will first have to convert the response from text to date.  This is a  three step process.  You would first use the sgapiGetValue function to get the response and the use the sgapiStrtotime function to convert the response from text to date.  You could then use the sgapiDate function to format the date.  Review the following example:

    %%xdate = sgapiStrtotime(sgapiGetValue(29));
    %%xdate = sgapiDate(“l”,%%xdate);

    I am not sure how you intend to use the date, so I am not sure what you would do with the ‘xdate’ variable.  One option would be to use the sgapiSetValue function to place the date in a hidden question.

    Jim Wetherill answered

      Fixed it – here’s the issue:

      Alex Walker answered

        Sorry Alex – I don’t know what to tell you.  It works on my end –

        How are you collecting the date from the respondent?

        Jim W (Moderator) answered

          Yes, I can verify that there are no loose spaces, but I still get bad syntax. I can’t adjust the date formatting, as I need it to appear in a UK format on the front end, but a different format elsewhere (with dashes too, not slashes)

          Alex Walker answered

            I tried it again on my end.  Make sure that there are no blank space behind the last line of code – there should be a return immediately after each semi-colon.

            If custom-scripting is not going to work for you could you adjust the date validation method you are using –

            Jim W (Moderator) answered


              Question stats

              • Active
              • Views23307 times
              • Answers8 answers
              • Followers1 follower