FileDateTime Question

bjwade62

Well-known member
Joined
May 25, 2006
Messages
50
Programming Experience
3-5
I can use FileDateTime("c:\temp\document.log") to retreive the date and time down to the seconds. That's the problem, I don't want it down to the second. Is there some sort of a trim method or function I can use to cut the seconds out?
Thanks,
Bernie
 
The return of that is a Date data type. You can do all the same things to that as any other Date object. Here is the list of Date members like properties and methods. I think you will find the ToShortTimeString function particularly interesting.
 
Thanks for the reply. Here's what I ended up using.

Dim dDate As String = Format(FileDateTime(SelFileName), "MM/dd/yyyy hh:mm tt")


The return of that is a Date data type. You can do all the same things to that as any other Date object. Here is the list of Date members like properties and methods. I think you will find the ToShortTimeString function particularly interesting.
 
That looks like VB6 code.
VB.NET:
'Get the last modified time of the specified file.
Dim fileTime As Date = IO.File.GetLastWriteTime("file path here")

'Remove the seconds.
fileTime = fileTime.AddSeconds(-fileTime.Second)
No Runtime functions (which Format and FileDateTime are) and you end up with a Date object instead of a String. You can then convert that Date to a string for display if you want, but you have a Date object that you can use for calculations and comparisons.
 
Back
Top