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: 
Anonymous
Not applicable

How to load the date of the file

Hola

Estoy usando un archivo de base de datos en Excel wich se genera en varias ocasiones durante el día. Tengo que cargar la fecha del archivo cuando fue creado o modificado con el fin de conocer el último informe cargado en QVfile date.JPG

Muchas gracias

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Have a look at

filetime([ filename ])

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.

View solution in original post

5 Replies
swuehl
MVP
MVP

Have a look at

filetime([ filename ])

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.

pamaxeed
Partner - Creator III
Partner - Creator III

Hola,

here you have the code snippet for looping through a directory for files and get the desired File information:

Let RootDirectory = Left(DocumentPath(), (index(DocumentPath(), '\', -1)-1));

Let CountChars = SubStringCount(RootDirectory,'\')+3;                               

sub BrowseDir(Root,n)

    for each FileExtension in 'pdf'                                                   

        for each FoundFile in filelist( Root & '\Documentos\*.' & FileExtension)       

            let FoundFile = PurgeChar(FoundFile , Chr(39));       

            FileList:

            Load *,

                 num(FileSize(Filepath),'# ### ### ###',',',' ') as FileSize,

                 FileTime(Filepath) as FileTime;

            load '$(FoundFile)' as Filepath,

                 subfield('$(FoundFile)','\',$(n)) as Filename,

                 left(subfield('$(FoundFile)','\',$(n)), 4) as ClientNumber,       

                 mid(subfield('$(FoundFile)','\',$(n)), 6, 2) as DocLanguage

            Autogenerate(1);

        next FoundFile

    next FileExtension

end sub

call BrowseDir(RootDirectory,CountChars);

Dates:

Load

    FileTime,

    Year(FileTime) as Year,

    Month(FileTime) as Month,

    Day(FileTime) as Day,

    Num(Round(now() - FileTime),'####') as 'Age(days)'

resident FileList;

Cheers,

Patric

Anonymous
Not applicable
Author

Hello swuehl.

Thanks a lot. It works just what I wanted it

Regards

Anonymous
Not applicable
Author

Hello Patric

I'm not so clever using large scripts and I could not achieve to work as I need . Anyway, I appreciate your answer

Regards

vinafidalgo
Partner - Creator
Partner - Creator

Looks like you got what you wanted.

Please mark the correct answer as correct, that way the topic will be closed.