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: 
stevelord
Specialist
Specialist

Function for the file's actual date created?

Hi, can someone provide me the function for the file's date created, and not the modified date?

filetime() is giving me the modified date and I need the created date or content created date.

Right now, I'm synchronizing historic file layouts to match them to current file setups as a one-time cleanup activity so my script can have an easy time picking the right worksheet and fields in a collection of excel files being loaded with a *.xlsx script.  When I correct the tab name or add the missing field etc, the modified date is jumping up to today, and the filetime() is changing to today.  (I could try maps and things, but by the time I click through all the files to see what's screwy. I could've fixed the spelling and such of whatever.)

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

If you use the File Sytem Object in a VBS macro, I think that object has a method to get the file created date. Search here or on the web for File System Object in VB script for more information.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
stevelord
Specialist
Specialist
Author

Thanks, but is there something simpler like a function() I can drop in the script to make a field for it?  I think QVMC doesn't let you setup automatic reloads of files that contain Macros (or maybe that it just doesn't run the Macro when it does the automatic reload).

anbu1984
Master III
Master III

If you want to use macro, check this link

time and date of created file (much like filetime)

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

There is no built-in function to do what you require. If you do the VB script as a function then you can call that function from the load script (as long as the function does not need to use objects or properties that are invalid while the script is loading). Passing a file name as a parameter, the function could get the create date which you could then load into a table.

Its a long time since I last did this, but if you define:

Public GetCreatedDate(strFilename)....

Then use it in a load like this:

     LOAD ....

          FileName() as Filename,

          GetCreatedDate(FileName()) As CreatedDate,

          ...

(as far as I recall )

Monitor the performance, as this type of macro can negatively impact on reload performance, and I don't know whether the server reload will work.

Another option is to batch schedule a vbscript file (.vbs extension) that you execute using cscript, that creates a list of file names and creation dates using the same vbs logic ahead of the reload. Your reload can then open this text file for the file create dates.

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein