0

Different results using Checkbox vs Button to update text field with today() using the exact same code

I was having an issue with dates not storing correctly with some of my code. The code was storing dates as the next day instead of current day. While trying to figure out where my problems were coming from, i setup a checkbox and a button with the EXACT same code. Either onUpdate or onClick my test text field should be populated with today's date. Instead I get this outcome:

  • Checkbox Outcome - when clicked it adds 1 day to the current day and puts that in the text field.
  • Button outcome - when clicked it fills the text field with the correct date. 

Here is the code I used on both button & checkbox

'date test 2' := format(today(), "MM/DD/YY");
'date test 3' := today()

I also included a formula field that simply displays today's date using "today()". It displays the correct date. 

"date test 2" field = type is "TEXT". 

"date test 3" field = type is "DATE". 

Any ideas on why this occurs? It's reminiscent of the timezone issue that Ninox had/has.

7 replies

null
    • Fred
    • 1 yr ago
    • Reported - view

    are you using the Cloud version? 

    testing on the MacOS, I don’t see the problem.

    When I use a button or Trigger on Update to modify a date field it works with:

    Date := today()

    It doesn’t work if I use:

    Date := format(today(),"MM/DD/YY")

    It sets the date as Jan 20 2020.

    If I write to a text field the above works.

    Can you post a sample of your DB?

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      Fred on Mac App, all triggers are executed locally, so the problem does not appear.
       

    • Firefly Team Events
    • James.3
    • 1 yr ago
    • Reported - view

    yes, the cloud version.

    • Firefly Team Events
    • James.3
    • 1 yr ago
    • Reported - view

    It's 10:26am here in California - I clicked the checkbox and it shows the correct date. I'm going to try it again later today and see what it does. To see if timezone is playing a part. Regardless, I don't see any reason that a checkbox or button should have yielded different results with the exact same code. 

    • Firefly Team Events
    • James.3
    • 1 yr ago
    • Reported - view

    It is 4:08 pm and when I click the checkbox it is now showing the wrong date ie increasing the day by one. Again, this feels a lot like the timezone issue Ninox has had for a long time. But usually I only experienced that with team members not in my own timezone. 

    Maybe I don't have enough skilled knowledge but this feels like a bug since a button with the same code works and the checkbox does not. 

    • Ninox partner
    • RoSoft_Steven.1
    • 1 yr ago
    • Reported - view

    It may have something to do with the execution of the triggers i guess.

    https://docs.ninox.com/en/script/appendix/transactions/execution-context

    Not sure if a trigger of a checkbox is executed on the server or the button does? (in any case, one is different from the other so it seems...)

    I'll have to check the source code of Ninox to know but I don't have the extended JS knowledge like Jacques TUR to check this out.

      • Ninox developper
      • Jacques_TUR
      • 1 yr ago
      • Reported - view

      @mass RoSoft_Steven I confirme, Trigger After Update run on server. The formula of button run on locale.

      today() on server is align to universal time zone (GTM 0) and it's cause of your issue.

      either you don't use a trigger that works on the server (see the link given by RoSoft_Steven ), or you use a function to calculate the date in your time zone:

      "------------------
      convert universal date time to local date time.
      -------------------";
      function universalToLocal(d : datetime,timeZone : number) do
          "// add the time zone to the numerical value of the universal date";
          number(d) + timeZone * 60 * 60 * 1000;
      end;
      
      "// retrieve the date in the time zone GTM+10
      date(universalToLocal(now(), 10));

      note : Beware of the summer/winter time difference which must be taken into account.

      Nick Massie and I have already sent a message to Ninox support about this. Send one too, the more we send, the faster the problem will be solved.

Content aside

  • 1 yr agoLast active
  • 7Replies
  • 171Views
  • 4 Following