• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

Display file attributes

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 = objFile.name	
		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

  • 2
1 Solution
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)
Option 2 should have been the shortdate - sorry!

strDateModified =  FormatDateTime(objFile.DateLastModified,2)

The other options and examples are listed at the sites below:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now