Rota Posted February 25, 2009 Share Posted February 25, 2009 Good buddies, How can I convert this date/time format (MM/DD/YYYY HH:MM or DD/MM/YYYY HH:MM) into YYYY/MM/DD HH:MM When I use _DateDiff to return the difference between 2 date, it doesn't work all the time, cause it requires the date/time format to compare should be YYYY/MM/DD HH:MM, any one could give me a hint? Thanks a ton Link to comment Share on other sites More sharing options...
exodius Posted February 25, 2009 Share Posted February 25, 2009 Good buddies, How can I convert this date/time format (MM/DD/YYYY HH:MM or DD/MM/YYYY HH:MM) into YYYY/MM/DD HH:MM When I use _DateDiff to return the difference between 2 date, it doesn't work all the time, cause it requires the date/time format to compare should be YYYY/MM/DD HH:MM, any one could give me a hint? Thanks a ton Actually _DateDiff requires "YYYY/MM/DD [HH:MM:SS]" (the time portion being optional). You can try using _DateTimeFormat in conjunction with _NowCalc(), or you're pretty much going to have to use StringSplit to split the string apart and put it back together in the format that's needed, or use a Regular Expression to pull the pieces you need out and put them back together once again. Here's an example of such munging together: #include <File.au3> #include <Date.au3> $FileList=_FileListToArray("C:\Documents And Settings", "*", 2) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf For $x = 1 to $FileList[0] $t = FileGetTime ("C:\Documents And Settings\" & $FileList[$x], 0) $varTimeStamp = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5] $varTimeDifference = _DateDiff ("D", $varTimeStamp, _NowCalc()) MsgBox (0, "Time Difference", "It's been " & $varTimeDifference & ' days since the profile "' & $FileList[$x] & '" was last accessed.') Next Link to comment Share on other sites More sharing options...
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