Skip to main content
Announcements
Qlik Community Office Hours, March 20th. Former Talend Community users, ask your questions live. SIGN UP
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get an automatically updated 'Date' in a QlikView sheet.

Hello!

I have a customer data sheet in one of my QlikView applications, to be used for the sales people when they want to check a certain customer. The sheet is designed with a 'Print date: YYYY-MM-DD' in text-box with the following formula: ' ='Print date:  ' & only(Today()) ', supposed to be updated automatically.

The update works when I look at the sheet in my version: QlikView Developer 8.5. However, when the users look at it, via the 'open in server' option, they see the old date from when I first created the text-box.

Please can anyone help me get this straight??

Best regards,

Louise

7 Replies
pat_agen
Specialist
Specialist

hi,

try

='Print date: ' & today(2).

the 2 makes the today() reevaluate when called. I have a similar text box but use the now(2) instead of today(). This works fine in v8.5 when being opened via the plug-in or as you do with the open in server option.

hope this helps

Not applicable
Author

Hi Pat!

Thank you very much for your help. It works great!! 🙂

//Louise

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi there,

You do need to be very careful when using the Now() function in a QV document.  It makes a continuous call to the server to get the current time.  Today() is not so bad - but I tend to avoid using it directly in a text box.

If the reload is happening frequently enough then I will set date variables in the load script with a Let statement. Obviously this only works if you reload frequently.

One way to get around this is to place an Action on a trigger - such as on Activate Sheet.  You can then use the External / Set Variable action to put the current date (or time) into a variable and then use this in a text box.

I would suggest that you just take a look at your CPU usage with and without that function being live to see if you notice a difference.


Regards,

Steve

Not applicable
Author

Hi Steve,

Thank you for your extra input :-).

Currently we reload automatically 8 times per 24 hrs. Would you say that is frequent enough?

Anyway, I do not use the Now() function, as we don't need the current time when the sheet is printed, only current date.

I will look into your suggestions a bit further on in the future. We're now planning to update our QlikView, from version 8.5 to 9 - or maybe we'll go straight to version 10, that's still not decided yet.

Regards,

Louise

johnw
Champion III
Champion III

Using now(), now(1) or today(1) aren't generally a problem in a text box.  They only ask the operating system for the current time once per second.  It should be a trivial amount of CPU.  Other versions of now() and today() are even safer, not asking the operating system for the current time at all.

Where it becomes a problem is if, say, you have a chart with ten thousand rows, and you do something like sum(if(MyTimestamp<now(),Value)).  If the chart takes over a second to render, this would bring your computer to its knees, locking it at 100% CPU and making it very difficult to even shut down the application.

So caution is called for, but you don't have to avoid these functions completely.  When in doubt, check your CPU usage as Steve said.

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi John,

Thanks for the clarification on time based functions.  I still feel on safer ground going via a variable!  The other advantage of setting a time variable on reload is that it reflects the time the data was reloaded - not when the user opens the document or sees the data - but this is just preference I guess.

Louise, regarding upgrading, there are some worthwhile new features in v10, and now that it is at SR2 it is seeming quite stable.  My recommendation would be to go straight to the latest version.

Regards,

Steve

johnw
Champion III
Champion III

I believe now(0) and reloadtime() both return a timestamp for when the script last finished reloading.  To get when the script started, though, I think you need a variable.  I'm using a variable for that purpose, anyway, so if someone knows how to get it with a function, I'd be happy to hear it! 

I can understand feeling safer with a variable, though.  QlikTech in the past changed the definitions of the now() function.  They could do it again, causing havok if you were depending on now(0), for instance, being what it is today, and you were casually using it in a chart, thinking everything was safe.