Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikView forum consolidation is complete. Labels are now required. LEARN ABOUT LABELS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Today() - Very Strange Result

I am using QlikView 9.0 Desktop to create a reporting interface. I am populating a variable vToday with Num(Today()). Today is 11/3/2009 but this returns 10/30/2009. The clock on my computer says 11/3, the clock on the server where the file is located says 11/3 and the server that has the database says 11/3 so why would QlikView say it is 10/30?

Any ideas?

1 Solution

Accepted Solutions
johnw
MVP
MVP

By default, today() returns the date that the document was opened, not today. I realize that's not exactly intuitive, but I suspect its QlikView trying to save people from themselves. You see, today(1), which actually returns today, polls the operating system every second, and can be used improperly in expressions such that your CPU caps out and never comes back. So just be careful with it. In any case, here are your options:

today(0) = when the document was loaded
today(1) = today
today() or today(2) = when you opened the document

View solution in original post

5 Replies
johnw
MVP
MVP

By default, today() returns the date that the document was opened, not today. I realize that's not exactly intuitive, but I suspect its QlikView trying to save people from themselves. You see, today(1), which actually returns today, polls the operating system every second, and can be used improperly in expressions such that your CPU caps out and never comes back. So just be careful with it. In any case, here are your options:

today(0) = when the document was loaded
today(1) = today
today() or today(2) = when you opened the document

View solution in original post

eiconsulting
Partner
Partner

I truly understand the process as it explained in the HELP you posted elsewhere. BUT I have the same problem of APPARENTLY random returns from TODAY(0) ... may be a bug (I'm still using v9).

I simply use a script that saves the date in a variable LET %oggi = Today(0); why should it give a different result than a simple Today(0) function in a text box?

While I am here I dispute that the document could have been opened or loaded several weeks in the past - I just opened and loaded it running the script. So even Today(2) shouldn't be that different.

I can try with Today(1) to be sure I should be able to reproduce the same condition that makes the "randomness" appear.

Flavio

eiconsulting
Partner
Partner

I have a possible answer to MYSELF Smile - Use always TODAY(1) in a script.

While you run a load the date of the last load is the previous one. ONE STEP BEFORE CURRENT (being executed) LOAD.

This would make using Today() Today(1) VERY STUPID in a script. There are system variables for lastLoad lastSave lastXX why confuse the water with Today?

Flavio

seebach
Luminary
Luminary

May I suggest using Now() instead, it defaults to parameter 1.

Not applicable

hi seebach,

Could you please elaborate little bit more how can you suggest Now().

Regards,

Rajesh