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

    Custom scripts are scary at first, but once you understand them you really start to see possibilities.

    Give it a try – insert an ACTION > CUSTOM SCRIPT on the survey page after the date question and copy/paste this script:

    %%xdate = sgapiStrtotime(sgapiGetValue(29));
    %%xdate = sgapiDate(“Y-m-d”,%%xdate);
    %%output .= %%xdate;

    The OUTPUT command should cause the date that was entered into qid29  to appear on the page in the YYYY-mm-dd format.  If it works, your next step should be to replace the OUTPUT command with a line that places the xdate as a response to a question:

    sgapiSetValue(??, %%xdate);

    The question marks (??) should be replaced by the question ID.  If you don’t want your respondent yo see the question then you can edit the question and use LOGIC RULE > HIDE THIS QUESTION BY DEFAULT.  This question would be the one that you pass to your application.

    Jim W (Moderator) 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
              • Views17903 times
              • Answers8 answers
              • Followers1 follower