erik7426 Posted March 7, 2014 Posted March 7, 2014 I am specifically looking at Friday. I have a script that will only be run on Friday's. If it is the 5th occurrence of a Friday in the month then the script needs to do some additional work. Is there a way to get AutoIt to calculate if 'today' is the 5th Friday of the month?
Danyfirex Posted March 7, 2014 Posted March 7, 2014 (edited) Hi, You should look into the date macros. Saludos Edited March 7, 2014 by Danyfirex Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Danp2 Posted March 7, 2014 Posted March 7, 2014 @WDAY will give you the day of the week. @MDAY will give you the day of the month. At first glance, those should be enough to accomplish your goal. Latest Webdriver UDF Release Webdriver Wiki FAQs
Damein Posted March 7, 2014 Posted March 7, 2014 As well as that, to keep track if how many Fridays it has been I would say use an ini or something, and each Friday it sets a variable to +1. If it reaches 5, you can use it then to activate your extra stuff. And if it's the first Friday then just reset the counter. I Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic
erik7426 Posted March 7, 2014 Author Posted March 7, 2014 (edited) I think I figured it out. Here's what I have... #include <Date.au3> $aNewDate = StringSplit(_DateAdd('D', -28, _NowCalcDate()), "/", 2) ; Subtracts 28 days from today and split into an array. $sToday = _DateToDayOfWeek(@YEAR, @MON, @MDAY) If $aNewDate[1] = @MON Then ; If the month 28 days does ago equals today's month then $FifthFriday = True Else $FifthFriday = False EndIf MsgBox(0,"",$FifthFriday) Does anyone see a potential problem with calculating it this way? Edited March 7, 2014 by erik7426
Danp2 Posted March 7, 2014 Posted March 7, 2014 (edited) Wouldn't this be simpler and just as accurate? Edit: Fix If statement to use @MDAY instead of @WDAY. If @WDAY = 6 Then If @MDAY > 28 Then $FifthFriday = True Else $FifthFriday = False EndIf MsgBox(0,"",$FifthFriday) Endif Edited March 7, 2014 by Danp2 Latest Webdriver UDF Release Webdriver Wiki FAQs
Solution erik7426 Posted March 7, 2014 Author Solution Posted March 7, 2014 Wouldn't this be simpler and just as accurate? If @WDAY = 6 Then If @WDAY > 28 Then $FifthFriday = True Else $FifthFriday = False EndIf MsgBox(0,"",$FifthFriday) Endif @WDAY would never be anything greater than 7. I guess I could have used... If @WDAY = 6 Then If @MDAY > 28 Then $FifthFriday = True Else $FifthFriday = False EndIf MsgBox(0,"",$FifthFriday) Endif
Danp2 Posted March 7, 2014 Posted March 7, 2014 Yeah... I had a typo in the posted code (now fixed). ;-) Latest Webdriver UDF Release Webdriver Wiki FAQs
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