Jump to content

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?

Link to comment
Share on other sites

Hi, You should look into the date macros.

Saludos

Edited by Danyfirex
Link to comment
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

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

Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...