Hiding a question based on date (New Zealand time zone)

0

Hi I would like to hide a question when a given date is reached e.g. triggering at 00:00 hours on 1 Dec 2015

How do I set up a rule based on New Zealand time not US EST.

Many thanks.

Paul.

 

Paul Nixon asked
    0

    Hi Rhys

    All working now after a few false starts :-) Had to manual retype the “U” into the script.

    Many thanks for your help with this. Can see lots of applications. In my current project I’m asking about an offer which has an expiry data and want to hide certain questions if the survey is being taken after the offer is no longer available.

    Cheers – Paul.

    Paul Nixon answered
      0

      Hi Paul,

      Apologies, I assumed you had worked with custom scripting before. You will need to know the ID of the question that you want to hide (note that this is not the question NUMBER, but the ID of the question. You can turn these on in the Customise menu at the top right when you are building your survey, I believe).

      Then, replace *ID* with your question ID number into the following syntax:

       

      %%timerightnow = sgapiDate(“U”);

      if ( %%timerightnow > 1448881200 ){
        sgapiHideQuestion( *ID*, true);
      }

       

      E.g. if your question ID was 2, it would look like this:

       

      %%timerightnow = sgapiDate(“U”);

      if ( %%timerightnow > 1448881200 ){
        sgapiHideQuestion( 2, true);
      }

       

      Cheers,
      Rhys

       

      Rhys Slattery answered
        0

        Many thanks Rhys.

        I have copied and amended your script to read as follows but I’me getting a bad syntax message.

        Can you tell me where I’ve gone wrong.

         

        %%timerightnow = sgapiDate(“U”);

        if ( %%timerightnow > 1448881200 ){
        %%output .= sgapiHideQuestion( %%2, true);
        }

         

        The script is on a page before the question to hide (ID=2)

        Thanks again – Paul.

        Paul Nixon answered
          0

          Hi Paul,

          This sounds like something that some custom scripting can handle – however, you’ll need to work in GMT.

          Try setting up a test survey and set up the following script (must be on any page before, or at the very least ABOVE the question on the same page):

           

          %%timerightnow = sgapiDate(“U”);

          if ( %%timerightnow > 1448881200 ){
          %%output .= “WORKS”;
          }

           

          What this does is take the current time in Unix format (e.g. number of seconds since Jan 1st 1970) and compares it to a pre-defined Unix timestamp, in this case, 1448881200 which is 11am GMT on the 30th of Nov – this should be midnight for NZ on the 1st of Dec. Then, replace the script within the curly brackets to whatever you want (e.g. if you want to hide a question, sgapiHideQuestion( %%questionid, true); ).

           

          Cheers,
          Rhys

          Rhys Slattery answered
            ×

            Login

            Question stats

            • Active
            • Views1639 times
            • Answers4 answers
            • Followers0 followers