Do As Server - Chapter 2

By David Gyenes, Senior Consultant

On the Facebook group Roger Mcilmoyle pointed out an “effect” using “do as server” processing the today() function. If you run this code (do as server today()end) you might get the previous day or the next day as result. Probably more of you wonder why this is happening.
Dates are calculated in Ninox in milliseconds starting from Jan 1, 1970 12:00 AMUTC. That is the absolute 0. Put this code into a formula and you will see the number representation of that day’s date:
You also can check the time associated with the date if you use this code:
Now you see that a date has a time as well, it is just not visible in the UI of Ninox. When you pick a date in a Date field it defaults to 12:00 AM, LOCAL TIME.
Notice the local time. The Server might be in a different time zone than you. If you
use the “do as server” running the today() function, you will get your today minus the time difference between you and the server. When that time difference gets added, depending on what part of the Globe you are on, you will see the previous or next day as result. It also depends on what time you run this code.
Ninox is working on converting the DATE field into a static date field so it won’t include the time (and time zone) data. That means if there are 2 different users using the same program and the users are in a different time zone they still will see the same date in the field.
How can you fix this issue for now? You can take away the time difference between you and the Server.
Example 1: your time zone is -5 and Server is +2 then add 7 hours:
     do as server
               ‘Date field’ := today() + time(7, 0)
Example 2: your time zone +3 and Server is +2 then subtract 1 hour:
     do as server
            ‘Date field’ := today() – time(1, 0)
How do I know my time zone? Put this code into a formula to show you:
     format(today(), “Z”)
How can I figure out the Server time zone? Create a Text Field to display the result and put this code into a button:
     do as server
               Text := format(today(), “Z”)
NOTE: Because of Daylight Savings time differences may vary depending on local rules for summer and winter time adjustments.