Display file attributes

Posted on 2011-05-09
Last Modified: 2012-05-11
I am trying to list the file properties (specifically the DateLastModified) of documents. I do not want to list the time. I only want the date. How do I get rid of the time in the strDateModified display?
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(DocFolder)

		For each objFile in objFolder.files
		strFileName =	
		strDateModified = objFile.DateLastModified
		strDisplayName = Left(strFileName,(InstrRev(strFileName, ".", -1)-1))
		strExtension = UCASE(Right(strFileName, (Len(strFileName)-InstrRev(strFileName, ".", -1))))
		Select Case strExtension
			Case "XLS" strFileType = "Excel"
			Case "DOC" strFileType = "Word"
			Case "PPT" strFileType = "PowerPoint"
			Case "PPS" strFileType = "PowerPoint"
			Case "PDF" strFileType = "PDF"
			Case "HTM" strFileType = "Web"
			Case "ASP" strFileType = "Web"
			Case "EXE" strFileType = "Executable"
			Case "MDB" strFileType = "Access"
			Case Else strFileType = "unknown"
		End Select		
		Response.write "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src=""\images\Icon" & strFileType & "sm.gif"" alt=""" & strFileType & " File"">&nbsp;&nbsp;"
		Response.write "<A target='_blank' HREF=""\" & relativeDocFolder & "\" & strfilename & """>" & strDisplayName & "</A> (" & strDateModified & "<br>" & vbcrlf

Open in new window

Question by:JLohman
    LVL 8

    Expert Comment

    You can use FormatDate to change the date-time display.
    if you update line 6 with the following it will show the date only.

    strDateModified =  FormatDateTime(objFile.DateLastModified,0)
    LVL 8

    Accepted Solution

    Option 2 should have been the shortdate - sorry!

    strDateModified =  FormatDateTime(objFile.DateLastModified,2)

    The other options and examples are listed at the sites below:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    I wanted to share this with fellow Experts, who might not know. How often have you wanted to learn something, only to be set back by either restrictions imposed on "trial" or "evaluation" software?  How often have you had to rebuild a home networ…
    User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
    Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
    The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now