Jump to content
Sign in to follow this  
erik7426

Help finding a specific day of the month

Recommended Posts

erik7426

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?

Share this post


Link to post
Share on other sites
Danyfirex

Hi, You should look into the date macros.

Saludos

Edited by Danyfirex

Share this post


Link to post
Share on other sites
Damein

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


MCR.jpg?t=1286371579

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

Share this post


Link to post
Share on other sites
erik7426

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 by erik7426

Share this post


Link to post
Share on other sites
Danp2

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 by Danp2

Share this post


Link to post
Share on other sites
erik7426

 

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

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  

×