File Creation date

  • Hi

    Is there anyway you can get the information about a file you have received i.e. the creation date, not using Filesystemobject....

    abdul


    abdul

  • You can try the following method, works fine.

    CREATE TABLE #tempTbl (

    [idx] [int] IDENTITY (1,1) NOT NULL,

    [val] [varchar] (8000) NULL

    )

    /*

    /T Controls which time field displayed or used for sorting

    timefield C Creation

    A Last Access

    W Last Written

    Just replace C:\NTDETECT.COM with the path and name of the file you want.

    */

    INSERT INTO #tempTbl (val) EXEC master..xp_cmdshell @val = 'DIR C:\NTDETECT.COM /T:C'

    SELECT

    CAST(LEFT(val,18) + 'm' as DATETIME) dateval

    FROM

    #tempTbl

    WHERE

    val IS NOT NULL AND

    val NOT LIKE '%Volume %' AND

    val NOT LIKE '%Directory %' AND

    val NOT LIKE '%File(s) %' AND

    val NOT LIKE '%Dir(s) %'

    DROP TABLE #tempTbl

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

  • unfortuantly I don't know the name of the file. It is zipped file of the name

    RSP_MIReportsddmmyy.zip.

    I have resorted to VB and have used the FileSystemobject...

    I created a little VB app, that would look for a .zip file in the current directory and then take its name and insert that into a table. I figured that the zip file could have been created on another day (possible) and that I could not ideally use the creation date but use the datpart of the filename (file names are RSP_MIReportddmmyy.zip). The little VB app writes used ADODB Command object to write the filename andthe datepart to two fields in a table. I then use one of the fields which contains just the datepart (filename field is there for a check) in my queries as required.

    I then call the vb exe in a step in my batch job...

    abdul


    abdul

  • You're code does work even if you don't supply the file name..

    e.g. EXEC master..xp_cmdshell 'DIR E:\Dev\Data\OrdercanceReject\*.zip /T:C'

    will give

    Volume in drive E is E

    Volume Serial Number is 942B-B387

    NULL

    Directory of E:\Dev\Data\OrdercanceReject

    NULL

    28/03/2002 23:26 1,874 xxxxxt.zip

    29/03/2002 00:00 5,107 yyyyy280302.zip

    2 File(s) 6,981 bytes

    0 Dir(s) 9,958,989,824 bytes free

    NULL

    so may be I should use this...

    abdul


    abdul

  • Great to hear you have a working possibility.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply