Sign in to follow this  
Followers 0
charon

Comparing two date strings problem

2 posts in this topic

I am comparing two string dates in the form of: "20140926". I have one cookie file that has this date but in my comparison with  todays date it doesn't match. I thought I was comparing two strings that contain numbers. WHy doesn't this work?

#include <MsgBoxConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <FileConstants.au3>


Example()

Func Example()

    $CurrentTime = @YEAR & @MON & @MDAY & @Hour & @Min & @SEC
    $TodaysDate = @YEAR & @MON & @MDAY
    $TodaysTime = @Hour & @Min & @SEC
    Local $cLength = StringLen($TodaysDate)
MsgBox($MB_SYSTEMMODAL, "", "DateTime " & $CurrentTime & " TodaysDate: " & $TodaysDate & " Clength: " & $Clength)

$Fpath = "C:\Users\dude\AppData\Roaming\Microsoft\Windows\Cookies\"
; List all the files and folders in the desktop directory using the default parameters.
    Local $aFileList = _FileListToArray($Fpath, "*.txt", 1, True)
    If @error = 1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Path was invalid.")
        Exit
    EndIf
    If @error = 4 Then
        MsgBox($MB_SYSTEMMODAL, "", "No file(s) were found.")
        Exit
    EndIf
    ; Display the results returned by _FileListToArray.
    _ArrayDisplay($aFileList, "$aFileList")



For $i = 0 To UBound($aFileList) - 1
    $x = FileGetTime($aFileList[$i], $FT_MODIFIED, 1)
    Local $iLength = StringLen($x)
    If $iLength > 8 Then
        Local $CookieDate = StringLeft($x, 8)
        Local $Length = StringLen($CookieDate)
        ;MsgBox($MB_SYSTEMMODAL, "", "Value of $x is: " & $x)
        MsgBox($MB_SYSTEMMODAL, "", "Value of CookieDate is: " & $CookieDate & " Length: " & $Length & " TodaysDate: " & $TodaysDate & " Clength: " & $Clength)
        If $TodaysDate = $x Then
            MsgBox("", "", "Found match", $x)
        EndIf
    EndIf
Next

Share this post


Link to post
Share on other sites



Nevermind. I found the bug in my comparison was using wrong variable.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0