Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How does function Today() work?

I'm using QV10 SR2 and I'm a little bit confused about function Today(). In help it states that there are 3 different modes:

0 Date at script run

1 Date at function call

2 Date when the document was opened

Default timer_mode is 2. The timer_mode = 1 should be used with caution, since it polls the operating system every second and hence could slow down the system.

But when I execute it in mode 2 (default) or 0, it gives me old dates. I would expect that...

  • 2 gives me the date when the document was opened. That means if it is reloaded by server then it should be the date when the server touches the document.
  • 0 gives me the date when the script runs. That means if it is reloaded by Server then it should be the date when script execution starts.
  • 1 gives me the date when the function is called. That means if it is reloaded by Server then it should be the date when exactly this function is reached while script execution.

So, what's wrong then?

19 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Then must Today() give also the right value!

Not applicable
Author

I'm with you, but don't forget I tested it by now and not on daily reload. It looks like the first reload on a new day returns the old date of the day before, every subsequently reload seems to work.

brenner_martina
Partner - Specialist II
Partner - Specialist II

ok, so that makes me crazy, too!

Not applicable
Author

It looks like it uses Today(0).

swuehl
MVP
MVP

May I ask where you use the today() call? In the script or UI?

And you use the Server to schedule the reload?

If you use it in the script and you want to make sure to always get the current date, I would suggest to use Today(1).

I think the script run date ( Today(0) ) will not be set before after the run has finished.

Not applicable
Author

Yeah, you are right. It's in the script and the reload is scheduled on server.

Right, my current workaround is to use Today(1). But from my point of view it should also work if I use Today() or Today(2). And help says something about performance issues when I use Today(1).

swuehl schrieb:

I think the script run date ( Today(0) ) will not be set before after the run has finished.


Yes, Martina already mentioned that.

swuehl
MVP
MVP

I believe you won't get any performance issues in the script. This note is considering UI use only, IMHO.

What I intended to say:

Today(0) will return the date of the last successful script run. So, on the first run of a day, you get the previous day returned (edit: if called from the script, like in this case!)

Not sure about today() / today(2), this might be depending on how the server handles your document while reloading / if your document is already open.

Not applicable
Author

Yeah, that's it. Help considers only use in UI, not in script.

That means if reload is done by server then the document isn't really open. If I use Today()/Today(2) in script then I get the date when I last opened the document in QV client. That means the only way to get around this is to use Today(1) instead (only true if used just in script)!!

Cheers everybody!

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

See http://qlikviewnotes.blogspot.com/2010/07/now-trap.html for more on this issue. The blog discusses now(), but applies to today() as well.

-Rob

http://robwunderlich.com

Anonymous
Not applicable
Author

Today(0) is the date of the previous reload not the date at script run !!!