Patchworks Posted September 5, 2011 Posted September 5, 2011 (edited) I've looked thru the forums and found lots of examples with file dates but not comparing a filedate to the system date. Dates are very funny with all the weird formatting and I can't seem to find a way to do it! I'm looking for how many hours old the file is. Can someone give me a hand please! Func FileHowOldHours( $cFile ) Local $TempFileDate = FileGetTime( $cFile , 0 ) Local $Date = @MON & "/" & @MDAY & "/" & @YEAR Local $JobLastRun = $TempFileDate[1] & "/" & $TempFileDate[2] & "/" & $TempFileDate[0] Return _DateDiff("h", $JobLastRun, $Date) EndFunc Edited September 5, 2011 by Patchworks
Patchworks Posted September 5, 2011 Author Posted September 5, 2011 Ok, 2nd attempt here!!! Func LogFileAgeInHours( $cLogFile ) Local $cFileDate = FileGetTime( $cLogFile , 0 ) Return _DateDiff("h", $cFileDate , _NowDate()) EndFunc
somdcomputerguy Posted September 5, 2011 Posted September 5, 2011 You weren't including the time in the $Date variable. Look at this code, modify it to your needs. Note that I used 's' (seconds) in the _DateDiff function, that was just for my testing. #include <Date.au3> Local $TempFileDate = FileGetTime( @ScriptName, 0 ) Local $JobLastRun = $TempFileDate[0] & "/" & $TempFileDate[1] & "/" & $TempFileDate[2] & " " & $TempFileDate[3] & ":" & $TempFileDate[4] & ":" & $TempFileDate[5] MsgBox(0, '', _NowCalc() & @CRLF & $JobLastRun & @CRLF & _DateDiff("s", $JobLastRun, _NowCalc())) - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Patchworks Posted September 5, 2011 Author Posted September 5, 2011 You weren't including the time in the $Date variable. Look at this code, modify it to your needs. Note that I used 's' (seconds) in the _DateDiff function, that was just for my testing. #include <Date.au3> Local $TempFileDate = FileGetTime( @ScriptName, 0 ) Local $JobLastRun = $TempFileDate[0] & "/" & $TempFileDate[1] & "/" & $TempFileDate[2] & " " & $TempFileDate[3] & ":" & $TempFileDate[4] & ":" & $TempFileDate[5] MsgBox(0, '', _NowCalc() & @CRLF & $JobLastRun & @CRLF & _DateDiff("s", $JobLastRun, _NowCalc())) Thanks bud, you help was crutial. Here is what I ended up with. Func LogFileAgeInHours( $cLogFile ) Local $cFileDate = FileGetTime( $cLogFile , 0 ) ;Get the Last Modified date and time Return _DateDiff("h", $cFileDate[0] & "/" & $cFileDate[1] & "/" & $cFileDate[2] & " " & $cFileDate[3] & ":" & $cFileDate[4] & ":" & $cFileDate[5] , _NowCalc()) EndFunc
somdcomputerguy Posted September 5, 2011 Posted September 5, 2011 Glad I could help. Good luck with the rest of your project. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now