# Help finding a specific day of the month

Go to solution Solved by erik7426,

## Recommended Posts

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 on other sites

Hi, You should look into the date macros.

Saludos

Edited by Danyfirex

AutoIt...

##### Share on other sites

@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.

##### Share on other sites

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

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 on other sites

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 on other sites

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 on other sites

• Solution

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 on other sites

Yeah... I had a typo in the posted code (now fixed). ;-)

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...