You are viewing limited content. For full access, please sign in.

Question

Question

Need Forms field calculation that populates "MONTHDAYHOURMINUTESECOND" with leading 0 on the "second" variable

asked on October 29, 2018

I need the Forms field calculation that populates "MONTHDAYHOURMINUTESECOND" with a leading 0 on the "SECOND" variable; here is an example:

What I need:  MONTHDAYHOURMINUTESECOND= (1029075203)

 

Here is the calculation that I currently have on the field:

=CONCATENATE(MONTH(NOW()), DAY(NOW()), HOUR(NOW()), MINUTE(NOW()), MINUTE(NOW()))

Which results in:  102975656 (The leading 0 in seconds is missing; it should be "06")

 

I tried changing the last variable to "SECOND", but that variable is not recognized:

=CONCATENATE(MONTH(NOW()), DAY(NOW()), HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()))

 

Does Forms support the last "SECOND" variable with a leading "0"?

0 0

Answer

SELECTED ANSWER
replied on November 6, 2018

We ended up using JavaScript to accomplish this:

 

    $( document ).ready(function() {
      var date=new Date();
      var mm = date.getMonth()+1;
      if(mm<10)
        {
          mm='0'+mm.toString();
        }
      var dd = date.getDate();
      if(dd<10)
        {
          dd='0'+dd.toString();
        }
      var hh = date.getHours();
      if(hh<10)
        {
          hh='0'+hh.toString();
        }
      var nn = date.getMinutes();
      if(nn<10)
        {
          nn='0'+nn.toString();
        }
      var ss = date.getSeconds();
      if(ss<10)
        {
          ss='0'+ss.toString();
        }
      var timestamp  = mm.toString()+dd.toString()+hh.toString()+nn.toString()+ss.toString();
      //alert( timestamp );
      $('#q1 input').val(timestamp);
      $('#q11 input').val(timestamp);
});

0 0

Replies

replied on November 1, 2018

Or will Forms let me assign two formulas to the same field?  For example:

 

=CONCATENATE(MONTH(NOW()), DAY(NOW()), HOUR(NOW()), MINUTE(NOW()), SECOND(NOW()))

 

and then a substitution formula that will let me replace 1, 2, 3, 4, 5, 6, 7, 8, and 9 on the "SECOND" variable with:

 

01, 02, 03, 04, 05, 06, 07, 08, 09

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.