The Now and Today functions can be used in a chart expression or in the script to return a timestamp or current date from the system clock, respectively. They each take one optional parameter (0, 1 or 2) that is used to indicate when the timestamp or day is captured. By default, the parameter is 1. Let’s look at some examples of the Now and Today functions using all 3 parameters and see how they differ.
Now(0) - Returns the timestamp of the last finished data reload.
Today(0) - Returns the day of the last finished data reload.
When using the 0 parameter, the timestamp or day can vary depending on when the reload occurred – it may be 5 minutes ago or one day ago as seen above. If you are using one of these functions in the script with the 0 parameter, note that the last finished reload will not be the reload that is currently running but rather the last finished reload (the reload that ran previously). In the example above, the last finished reload was yesterday, December 6th.
To get the day or timestamp of the current reload, use 1 as the parameter or no parameter as seen below.
Now(1) or Now() - Returns the timestamp of the function call in the current reload.
Today(1) or Today() - Returns the day of the function call in the current reload.
When using the 1 parameter, the results will vary depending on if the function is being used in a chart expression or in the script. In a chart expression, the timestamp or day will be when the expression is added/created or refreshed. For instance, if I refresh a sheet that is using the Now function in an expression, the timestamp will be updated to when that function was called in the refresh. If these functions are being used in the script with the 1 parameter, keep in mind that the Now and Today functions will reflect the timestamp or day when the app was reloaded. Therefore, if you are looking at the results of these functions the next day or a week later, they will look old because they are reflecting the timestamp or day of when the app was reloaded (which may not be the current day).
Using 2 as a parameter will show the timestamp or day when the app was opened.
Now(2) - Returns the timestamp when the app was opened.
Today(2) - Returns the day when the app was opened.
The parameters used in the Now and Today functions allow users to pinpoint when they want the timestamp and/or day captured. I have used these functions with other functions such as the Date function to format the timestamp and/or day and the ConvertToLocalTime function to convert the system timestamp and/or day to another time zone. There are many ways the Now and Today functions can be used in chart expressions and within the script.
For more information, visit https://community.qlik.com/t5/Qlik-Design-Blog/The-Now-amp-Today-Functions/ba-p/1518108