Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

File created time

Hello,

Is there a way to get the creation time of a text file. I know about filetime() but that function results in the date and time of last modification.

Kind regards,

Mark

1 Solution

Accepted Solutions
Not applicable
Author

Hi,

I made some tests ...

The return of a method does not seem to work without casting the VBScript-datetime to string ...

Have a look at the attached example (Module & Load-Script) ...

Best regards
Stefan

P.S.: Note: You need to have the file C:\test.txt for my demo ...

View solution in original post

9 Replies
Not applicable
Author

I think you would have to use vbscript & FileSystemObject

Function ShowDateCreated(filespec)
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
ShowDateCreated = f.DateCreated
End Function

You could integrate this function into modules and also use it in your load-script.

Best regards

Stefan

Not applicable
Author

Dear Stefan,

Thank you for your suggestion. I knew that I could get the file creation date using Vbscript. I only never used VbScript functions in my load script. Are there any specific things that I need to do?
I just copied your function in the Module Editor, and created a variable in my loadscript:

LET temp=ShowDateCreated('C:\Test.txt');

But it does not work, what am I doing wrong? Also making the fuction public does not help..

Kind regards,

Mark

Not applicable
Author


Mark wrote:
Dear Stefan,
Thank you for your suggestion. I knew that I could get the file creation date using Vbscript. I only never used VbScript functions in my load script. Are there any specific things that I need to do?
I just copied your function in the Module Editor, and created a variable in my loadscript:

LET temp=ShowDateCreated('C:\Test.txt');

But it does not work, what am I doing wrong? Also making the fuction public does not help..
Kind regards,
Mark<div></div>


Hi,

when using functions like this you have to adopt the security settings ("Allow system access") ... Have you checked this?

Best regards

Stefan

Not applicable
Author


stwxy75 wrote:
<pre>
Mark wrote:
Dear Stefan,
Thank you for your suggestion. I knew that I could get the file creation date using Vbscript. I only never used VbScript functions in my load script. Are there any specific things that I need to do?
I just copied your function in the Module Editor, and created a variable in my loadscript:

LET temp=ShowDateCreated('C:\Test.txt');

But it does not work, what am I doing wrong? Also making the fuction public does not help..
Kind regards,
Mark<div></div>

Hi,

when using functions like this you have to adopt the security settings ("Allow system access") ... Have you checked this?

Best regards

Stefan



Yes, secuity settings are already on "allow system access".

Not applicable
Author

Hi,

I made some tests ...

The return of a method does not seem to work without casting the VBScript-datetime to string ...

Have a look at the attached example (Module & Load-Script) ...

Best regards
Stefan

P.S.: Note: You need to have the file C:\test.txt for my demo ...

Not applicable
Author

Dear Stefan,

Thank you for your solution. It works, the problem was indeed that the function couldn't return a datatime type. Casting to a string was the solution.
The only problem I have now is that when reloading the script using QV 9 x64 Server, the function does not wrok. When using a local client everything works perfect. It's maybe caused by the macro security, but I these settings are already on the right values both on QV Server as in the Module Editor. Any suggestions?

Kind regards,

Mark

Not applicable
Author

Do you have the possibility to run the script manually on your server to test if it works?

(Open the QlikView application on the server) ...

Best regards

Stefan

blaise
Partner - Specialist
Partner - Specialist

I think that FileSystemObject is treated different on XP, WS2003 and possibly Vista/7

Not applicable
Author


blaise wrote:
I think that FileSystemObject is treated different on XP, WS2003 and possibly Vista/7<div></div>


I have tested this on XP, Vista, and Windows 7, but not on WS2003 but I don't think it's different there ...

Best regards

Stefan