Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Trying to find a date between two other dates

$
0
0
Not sure how to fix this function...I want the Return to be true if today's date falls between the start date and the end date. I really thought I had this figured out until I ran across an issue where the start date is in the prior month and the end date is in the current month.

Any help?

My raw data is as such:

!< START 2013-01-31
!< ENDS 2013-02-07
!< TODAY 2013-02-05


[ autoit ]         
Func CheckTodaysDate($Starts, $Ends, $Today)     ConsoleWrite('CALLING CheckTodaysDate -->' & @CRLF & @CRLF)     ConsoleWrite("!< START " & $Starts & @CRLF)     ConsoleWrite("!< ENDS " & $Ends & @CRLF)     ConsoleWrite("!< TODAY " & $Today & @CRLF)     ConsoleWrite(@CRLF)     Local $aStarts = StringSplit($Starts, '-')     Local $aEnds = StringSplit($Ends, '-')     Local $aToday = StringSplit($Today, '-')     ConsoleWrite(@CRLF)     For $x = 0 To UBound($aStarts) - 1         ConsoleWrite($x & ' = ' & $aStarts[$x] & '   ')     Next     ConsoleWrite(@CRLF)     For $x = 0 To UBound($aEnds) - 1         ConsoleWrite($x & ' = ' & $aEnds[$x] & '     ')     Next     ConsoleWrite(@CRLF)     For $x = 0 To UBound($aToday) - 1         ConsoleWrite($x & ' = ' & $aToday[$x] & '    ')     Next     ConsoleWrite(@CRLF)     ConsoleWrite(@CRLF & 'CHECKING -->> STARTS ' & $Starts & ' ENDS ' & $Ends & ' ? TODAY ' & $Today & @CRLF)     If $aStarts[1] = $aToday[1] Or $aEnds[1] = $aToday[1] Then         If $aStarts[2] = $aToday[2] Or $aEnds[2] = $aToday[2] Then             If $aStarts[3] = $aToday[3] Or ($aStarts[3] <= $aToday[3] And $aEnds[3] >= $aToday[3]) Or $aEnds[3] = $aToday[3] Then                 ;MsgBox('', 'Change Today', '')                 ConsoleWrite('MATCH FOUND -->> ' & $Starts & ')' & ' (ENDS = ' & $Ends & ')' & ' (Today = ' & $Today & ')' & @CRLF)                 ConsoleWrite('-->' & @CRLF & @CRLF)                 Return True             Else                 ConsoleWrite('WRONG DAY NO MATCH (STARTS = ' & $Starts & ')' & ' (ENDS = ' & $Ends & ')' & ' (Today = ' & $Today & ')' & @CRLF)                 ConsoleWrite('-->' & @CRLF & @CRLF)             EndIf         Else             ConsoleWrite('WRONG MONTH NO MATCH (STARTS = ' & $Starts & ')' & ' (ENDS = ' & $Ends & ')' & ' (Today = ' & $Today & ')' & @CRLF)             ConsoleWrite('-->' & @CRLF & @CRLF)             Return False         EndIf     Else         ConsoleWrite('WRONG YEAR -->> NO MATCH (STARTS = ' & $Starts & ')' & ' (ENDS = ' & $Ends & ')' & ' (Today = ' & $Today & ')' & @CRLF)         ConsoleWrite('-->' & @CRLF & @CRLF)         Return False     EndIf EndFunc   ;==>CheckTodaysDate

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>