[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • 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
		Next

Open in new window

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

strDateModified =  FormatDateTime(objFile.DateLastModified,2)

The other options and examples are listed at the sites below:
http://msdn.microsoft.com/en-us/library/8aebkz6s(v=vs.85).aspx
http://www.w3schools.com/vbscript/func_formatdatetime.asp
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

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