I have found that when a load script references the today() function, the result is actually the day the document was last reloaded. This breaks calculations where the document is reloaded once per day because today() is always yesterday.
The function reference:
says "If you use the function in a load script, timer_mode=0 will result in the day of the last finished data load, while timer_mode=1 will give the day of the current data load."
What is the default? I believe I have observed today(1) returning yesterday as well--has this been seen by others?
It is not a bug but it might very well not be what you expect. A bug is something that is not working as specified.
Be aware that the Today() you use when a load script is run is based on the run date. I find that completely natural. How could a load script know that you would look at the results it calculated one, two or three days into the future?
But if you use Today() in your UI in some expression it will relate to current time although the optional parameters you provide will determine which variant of "today" you are getting. It has a lot of flexibility that might confuse people.
based on my testing, the result of today() in a load script is the date when the script was last loaded. The first time a script is loaded today, the result of today() is yesterday. That seems to match with today(0). The documentation does not specify the default so I do not know if it is a bug or not.
Well it is very handy to have the last reload day to find the interval between the current reload and the previous. I agree that the documentation could have been much clearer and state what is default.
my scripts need a deterministic value for today like getdate(). We are removing the logic from qlikview and going to the database server for a reliable timestamp instead of using today(). However there are some scripts where there is no database connection...have tried doing floor(now()), but it appears to be the same logic behind both functions, so I wonder if the bug is present in the now(1) function also.
My testing of today(1) returns the date when the script was last reloaded, not the value of the date when the function is evaluated in the current load script. I just wondered if other people had seen this or if I am making mistakes somewhere.
Of course you are free to do that - but I don't understand that you can say that the Qlik values aren't deterministic.
You could have a look at this load script and it reveals how the dates are: