Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
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?

1 Solution

Accepted Solutions
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

View solution in original post

19 Replies
brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi, einsTeln.NET,

I think it is easy, you get allways the systemdate from windows:

2 = date from today only one systemcall at reload the document (not only from Server, even direct reload)

0 = date of the last reload (not only from Server, even direct reload) and this is not like Date(ReloadTime())

1 = date, that is permanently checked with the system

Greetings from Munich

Martina

EVACO GmbH

Not applicable
Author

Yeah, I know that it is looking at system's clock. I already checked if the clock is alright.

Ok, that would mean if I use mode 0 (last reload) and I reload once a day then it would give me always the date of the last day. That is not what I want.

If mode 2 should give me the date when the current reload started then it definitely doesn't work (or in contrast to what is stated in help mode 2 isn't default).

brenner_martina
Partner - Specialist II
Partner - Specialist II

once again:

today() or Today(2) means the systemdate of your computer resp. server.

today(0) is the date of the previous reload

ReloadTime() is the timestamp of your last reload

Not applicable
Author

Yeah, I understand. But Today() [which should be the same like Today(2)] gives me an old date even though the server's system date is correct. I scheduled a reload of that document at about 2 o'clock am and it gives me the date of the day before.

brenner_martina
Partner - Specialist II
Partner - Specialist II

are you sure, that the date on the server is right?

Not applicable
Author

Yes, I checked it several times. I think I'm going mad...

brenner_martina
Partner - Specialist II
Partner - Specialist II

Try the function Now() or Date(Now()) to look at the date of the server. But be careful, it shows every second.

Miguel_Angel_Baeyens

Hi,

Today() returns always using the format stored into the script DateFormat variable (usually at the top of the first tab). Is that format correct? What does it return when you use Now() instead? (Should get the current date and time).

Regards.

Miguel

Not applicable
Author

Now() gives me the current datatime, works! Date format is also correct.