Saturday, March 7, 2015

How Many Days Since That Document Reloaded?

I was challenged to write a simple blog posting. Here it is, although it still has some code in it.

A recent project required a document to “know” how many days ago a separate .qvw document had been reloaded. This statement in the loadscript uses the pathname to the separate document and puts the answer to “how many days ago” in the variable vDaysAgo:

LET vDaysAgo = Now() - FileTime('e:\ventures\PriceAnalysis.qvw'); 


  ★★★

  

4 comments:

Andrew Walker said...

I don't think that works. To quote QV help the Filetime script function
'Returns a timestamp for the date and time of the last modification of the file'.
So we'll get to know when the QV file in question was last saved rather than when last reloaded.

Cheers

Andrew

-TB said...

I believe you are correct, Andrew. For the environment that I was working in, all reloading was done as a batch process and documents were saved after reloading. If someone reloaded a document but did not save it then there would be no way to tell by looking at the document file on disk.

kiran ch said...

Hi how to have FileTime() function , is it there in QV .

Thanks
Kiran Kumar

-TB said...

Hi Kiran,

The FileTime function is available in the QlikView loadscript. Here's some info from the HELP button:

Returns a timestamp for the date and time of the last modification of the file filename. If no filename is specified, the function will refer to the currently read table file.

Examples:

filetime( 'xyz.xls' )

Will return the timestamp of the last modification of the file xyz.xls.

Load *, filetime() as X from abc.txt ;

Will return the date and time of the last modification of the file (abc.txt) as a timestamp in field X in each record read.

Thanks for your question.
-Tim