# Removing Saturday and Sunday from a count of dates

## Recommended Posts

I created a little script to give me the number of days left before the end of the school year. Additionally, I took out Saturday and Sundays to just return a count of school days. But, I am guessing this is not the most elegant solution since I make an array of available dates and then remove the Saturdays and Sundays. Anyone else have a better idea of how I could have achieved this?

```;Count the number of days left in school
#AutoIt3Wrapper_Run_Tidy=Yes
#include
#include

Local \$sLastDayOfSchool = "2013/06/12"
Local \$sTodaysDate = @YEAR & "/" & @MON & "/" & @MDAY
Local \$sStartDate = \$sTodaysDate

Local \$iDaysCalc = _DateDiff('d', _NowCalc(), \$sLastDayOfSchool); Calculated the number of days left
Local \$sNewDate
Local \$aArrayOfDates[1]

;Figure out how many weekdays are left
; ....Try making an array of dates, then taking out Sat and Sun? Seems like there should be a better way

Do
\$sStartDate = \$sNewDate
\$sSplitDate = StringSplit(\$sNewDate, "/") ;Split the date, so we can remove the Saturdays and Sundays
\$iDateAsDayOfWeek = _DateToDayOfWeek(\$sSplitDate[1], \$sSplitDate[2], \$sSplitDate[3]) ;Return the days as an integer (Sun =1, Sat = 7)

If Not ((\$iDateAsDayOfWeek == 1) Or (_DateDayOfWeek(\$sNewDate) == 7)) Then ;Remove all 1's and 7's (Sun/Sat)
EndIf
Until (\$sNewDate = \$sLastDayOfSchool) ;Stop on the last Day of school
\$aArrayOfDates[0] = UBound(\$aArrayOfDates) - 1 ;Make the 0-index = the Ubound

;~ _ArrayDisplay(\$aArrayOfDates)

MsgBox(0, "Countdown", \$iDaysCalc & " total days left" & @CRLF & \$aArrayOfDates[0] & " school days left")```

##### Share on other sites

another example:

```#include <Date.au3>

#include <Date.au3>
Local \$sLastDayOfSchool = "2013/06/12"
Local \$sTodaysDate = @YEAR & "/" & @MON & "/" & @MDAY
\$sDate = \$sTodaysDate
\$iDaysLeft = 0
While _DateDiff('d', \$sDate, \$sLastDayOfSchool) > 0
\$aTemp = StringSplit(\$sDate, "/")
\$iDate =_DateToDayOfWeek(\$aTemp[1], \$aTemp[2], \$aTemp[3])
ConsoleWrite(\$iDate & " " )
If \$iDate <> 1 And \$iDate <> 7 Then
\$iDaysLeft += 1
EndIf
ConsoleWrite(\$iDaysLeft & @CRLF)
WEnd
MsgBox(1, 1, \$iDaysLeft)```
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

##### Share on other sites

I created a little script to give me the number of days left before the end of the school year. Additionally, I took out Saturday and Sundays to just return a count of school days. But, I am guessing this is not the most elegant solution since I make an array of available dates and then remove the Saturdays and Sundays. Anyone else have a better idea of how I could have achieved this?

Are you sure it is even working correctly?

I think this line is wrong as the second test after the Or seems to be off:

`If Not ((\$iDateAsDayOfWeek == 1) Or (_DateDayOfWeek(\$sNewDate) == 7)) Then ;Remove all 1's and 7's (Sun/Sat)`

SciTE4AutoIt3 Full installer Download page Â  -Â Beta filesÂ  Â  Â  Â  Â  Â
Â
Live for the present,
Dream of the future,
Learn from the past.
Â

##### Share on other sites

Are you sure it is even working correctly?

I think this line is wrong as the second test after the Or seems to be off:

`If Not ((\$iDateAsDayOfWeek == 1) Or (_DateDayOfWeek(\$sNewDate) == 7)) Then ;Remove all 1's and 7's (Sun/Sat)`

You know, you might be correct. It works, in that it produces a result, but that 2nd test does look off, I'll go back and verify. Thanks for catching that!

another example:

```#include <Date.au3>

#include <Date.au3>
Local \$sLastDayOfSchool = "2013/06/12"
Local \$sTodaysDate = @YEAR & "/" & @MON & "/" & @MDAY
\$sDate = \$sTodaysDate
\$iDaysLeft = 0
While _DateDiff('d', \$sDate, \$sLastDayOfSchool) > 0
\$aTemp = StringSplit(\$sDate, "/")
\$iDate =_DateToDayOfWeek(\$aTemp[1], \$aTemp[2], \$aTemp[3])
ConsoleWrite(\$iDate & " " )
If \$iDate <> 1 And \$iDate <> 7 Then
\$iDaysLeft += 1
EndIf
ConsoleWrite(\$iDaysLeft & @CRLF)
WEnd
MsgBox(1, 1, \$iDaysLeft)```

I like this! Yea, that is more elegant. Thanks for taking the time to show me another approach.

##### Share on other sites

Another approach:

You only need to examine the first (partial) and last (partial) weeks of the time range by day. The rest can be processed by week.

Start by processing every day until you reach a monday (first week is complete). Add 7 to the day count. If the date is still in the range, add 5 to the total day count. If it is out of range, go back six days and then process every day.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2020-07-21 - Version 1.5.1.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2020-06-27 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
ExcelÂ - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

Â

##### Share on other sites

Without any loop:

```#include <Date.au3>

Local \$Date1 = "2013/05/02"
Local \$Date2 = _NowCalcDate()

ConsoleWrite("There are " & _WorkDays(\$Date1, \$Date2) & " work days (Mon..Fri) between " & \$Date1 & " and " & \$Date2 & " (included)." & @LF)

Func _WorkDays(\$DateFrom, \$DateTo)
Local \$Date = StringSplit(\$DateFrom, '-/', 2)
Local \$DayFrom = _DateToDayOfWeekISO(\$Date[0], \$Date[1], \$Date[2]) - 1
\$Date = StringSplit(\$DateTo, '-/', 2)
Local \$DayTo = _DateToDayOfWeekISO(\$Date[0], \$Date[1], \$Date[2]) - 1
Local Const \$ExtraDays[7][7] = [[0, 1, 2, 3, 4, 4, 4],[4, 0, 1, 2, 3, 3, 3],[3, 4, 0, 1, 2, 2],[2, 3, 4, 0, 1, 2, 2],[1, 2, 3, 4, 0, 1, 2],[1, 2, 3, 4, 5, 0, 1],[1, 2, 3, 4, 5, 5, 0]]
Return (Floor(_DateDiff('D', \$DateFrom, \$DateTo) / 7) * 5 + \$ExtraDays[\$DayFrom][\$DayTo] + 1)
EndFunc ;==>_WorkDays```

Leave or remove the +1 in the result returned depending on whether you count today-->today as 1 day or 0.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

@jchd

Very nice. Can you explain how you came up with the \$ExtraDays array to me?

Also, shouldn't the return line be?

`Return (Floor(_DateDiff('D', \$DateFrom, \$DateTo) / 7) * 5 + \$ExtraDays[\$DayFrom-1][\$DayTo-1])`

I also found that having the +1 at the end may end up including a Sat or Sun.

edit: I suppose you could always deduct 1 from _DateToDayOfWeekISO funcs.

Edited by spudw2k

Spoiler

Things I've Made: AOT Tool â—ŠÂ AU History â—ŠÂ Deck of Cards â—Š HideIt â—Š ICU â—Š Icon Freezer â—Š Ipod Ejector â—Š Link Downloader â—Š MD5 Folder Enumerator â—Š PassGen â—ŠÂ Ping Tool â—Š Quick NIC â—Š Read OCR â—Š RemoteIT â—Š SchTasksGui â—Š SpyCam â—Š â—Š Transparency MachineÂ
Misc Code Snippets: ADODB Example â—Š CheckHoverÂ â—ŠÂ Detect SafeMode â—Š DynEnumArray â—Š GetNetStatDataÂ â—Š HashArrayâ—Š Local Admins â—Š Make Choice â—Š Recursive File List â—Š
Projects: Drive Space Usage GUI â—ŠÂ LEDkIT â—Š Plasma_kIt â—ŠÂ Scan Engine Builder â—Š SpeeDBurner â—Š SubnetCalc
Cool Stuff:

Â

##### Share on other sites

You can try this one. It is a German version of getting the working days.

```#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#region ### START Koda GUI section ### Form=
\$GUI = GUICreate("Anzahl Arbeitstage per AutoIt", 321, 169, 192, 124)
GUICtrlCreateGroup("", 8, 0, 305, 161)
GUICtrlCreateLabel("StartDatum", 16, 28, 57, 21)
GUICtrlCreateLabel("EndeDatum", 16, 52, 60, 21)
\$start_D = GUICtrlCreateDate(_NowCalcDate(), 120, 24, 186, 21, \$DTS_SHORTDATEFORMAT)
\$end_D = GUICtrlCreateDate(_NowCalcDate(), 120, 48, 186, 21, \$DTS_SHORTDATEFORMAT)
\$state_CB = GUICtrlCreateCombo("01 SH Schleswig-Holstein", 120, 72, 185, 25)
GUICtrlSetData(-1, "02 HH Hansestadt Hamburg|03 NI Niedersachsen|04 HB Freie Hansestadt Bremen|05 NW Nordrhein-Westfalen" & _
"|06 HE Hessen|07 RP Rheinland-Pfalz|08 BW Baden-WÃ¼rttemberg|09 BY Bayern|10 SL Saarland|11 BE Berlin|12 BB Brandenburg|13 MV Mecklenburg-Vorpommern" & _
"|14 SN Freistaat Sachsen|15 ST Sachsen-Anhalt|16 TH ThÃ¼ringen", "")
GUICtrlCreateLabel("Bundesland", 16, 76, 60, 21)
GUICtrlCreateLabel("Anzahl Arbeitstage", 16, 100, 92, 21)
\$wdays_I = GUICtrlCreateInput("", 120, 96, 185, 21)
GUICtrlCreateGroup("", 8, 120, 305, 41)
\$calc_B = GUICtrlCreateButton("Berechnen", 16, 130, 139, 25, \$WS_GROUP)
\$exit_B = GUICtrlCreateButton("Beenden", 168, 130, 139, 25, \$WS_GROUP)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
;~ #EndRegion ### END Koda GUI section ###

While 1
\$nMsg = GUIGetMsg()
Switch \$nMsg
Case \$GUI_EVENT_CLOSE
Exit (0)
Case \$exit_B
Exit (0)
Case \$calc_B
ConsoleWrite(_GetWorkingDaysInRange('01.01.2011', '07.01.2011', '') & @CRLF)
EndSwitch
WEnd

; \$iCountWorkDays = Standard-Arbeitstage (5= Mo-Fr; 6=Mo-Sa; 7=Mo-So)
; Ãœbergabe deutsches Datum: TT.MM.JJJJ, ; \$vFederalState = Index oder KÃ¼rzel des BuLandes, Bundesweit Gesetzlich (BG) = 0
Func _GetWorkingDaysInRange(\$sFromDate, \$sToDate, \$vFederalState, \$iCountWorkDays = 5)
Local \$aSplitFrom = StringSplit(\$sFromDate, '.', 2)
Local \$aSplitTo = StringSplit(\$sToDate, '.', 2)
Local \$aYears[1] = [\$aSplitFrom[2]] ; fÃ¼r jahresÃ¼bergreifende Daten
If \$aSplitTo[2] <> \$aSplitFrom[2] Then
ReDim \$aYears[\$aSplitTo[2] - \$aSplitFrom[2] + 1]
For \$i = 1 To UBound(\$aYears) - 1
\$aYears[\$i] = \$aYears[\$i - 1] + 1
Next
EndIf
Local \$aHolidays, \$iWorkingDayCounter = 0, \$n = 0, \$sTmpDate
Switch UBound(\$aYears)
Case 1 ; Datumswerte in einem Jahr
\$aHolidays = _Feiertage(\$aYears[0], \$vFederalState, 0, 0, 1)
Do
\$sTmpDate = _DateAdd('D', \$n, \$aSplitFrom[2] & '/' & \$aSplitFrom[1] & '/' & \$aSplitFrom[0])
\$iWorkingDayCounter += _IsWorkingDay(\$aHolidays, \$sTmpDate)
\$n += 1
Until \$aSplitTo[2] & '/' & \$aSplitTo[1] & '/' & \$aSplitTo[0] = \$sTmpDate
Case 2 ; Datumswerte in zwei Jahren
\$aHolidays = _Feiertage(\$aYears[0], \$vFederalState, 0, 0, 1)
Do
\$sTmpDate = _DateAdd('D', \$n, \$aSplitFrom[2] & '/' & \$aSplitFrom[1] & '/' & \$aSplitFrom[0])
\$iWorkingDayCounter += _IsWorkingDay(\$aHolidays, \$sTmpDate)
\$n += 1
If \$aSplitFrom[2] & '/12/31' = \$sTmpDate Then \$aHolidays = _Feiertage(\$aYears[1], \$vFederalState, 0, 0, 1)
Until \$aSplitTo[2] & '/' & \$aSplitTo[1] & '/' & \$aSplitTo[0] = \$sTmpDate
Case Else ; Datumswerte Ã¼ber mehr als 2 Jahre
Local \$tmpYear, \$index = 0, \$sDateEnd = \$aSplitTo[2] & '/' & \$aSplitTo[1] & '/' & \$aSplitTo[0]
\$aHolidays = _Feiertage(\$aYears[\$index], \$vFederalState, 0, 0, 1)
Do
\$sTmpDate = _DateAdd('D', \$n, \$aSplitFrom[2] & '/' & \$aSplitFrom[1] & '/' & \$aSplitFrom[0])
\$iWorkingDayCounter += _IsWorkingDay(\$aHolidays, \$sTmpDate)
\$n += 1
\$tmpYear = StringLeft(\$sTmpDate, 4)
If \$tmpYear & '/12/31' = \$sTmpDate And \$tmpYear & '/12/31' <> \$sDateEnd Then
\$index += 1
\$aHolidays = _Feiertage(\$aYears[\$index], \$vFederalState, 0, 0, 1)
EndIf
Until \$sDateEnd = \$sTmpDate
EndSwitch
Return \$iWorkingDayCounter
EndFunc ;==>_GetWorkingDaysInRange

Func _IsWorkingDay(ByRef \$aHolidays, \$sDate, \$iCountWorkDays = 5)
Local \$sFreeDay = 'N' ; 7 Werktage, ./. frei
If \$iCountWorkDays = 5 Then ; 5 Werktage, Sa/So frei
\$sFreeDay = '6 7'
ElseIf \$iCountWorkDays = 6 Then ; 6 Werktage, So frei
\$sFreeDay = '7'
EndIf
Local \$aSplitDate = StringSplit(\$sDate, '/', 2)
Local \$iWeekday = _DateToDayOfWeekISO(\$aSplitDate[0], \$aSplitDate[1], \$aSplitDate[2])
If @error Then Return 0
If StringInStr(\$sFreeDay, \$iWeekday) Then Return 0 ; ist Sa./So. = kein WorkingDay
Local \$index = _ArraySearch(\$aHolidays, \$sDate, 0, 0, 1)
If \$index = -1 Then Return 1 ; nicht in Feiertagen (u. kein Sa./So.) = WorkingDay
Local \$sDay = StringRight(\$sDate, 5)
ConsoleWrite(\$sDay & @CRLF)
If \$sDay = '12/24' Or \$sDay = '12/31' Then
ConsoleWrite("0.5 Tg" & @CRLF)
Return 0.5 ; Halber Feiertag (24./31. Dez.)
EndIf
Return 0 ; in Feiertagen = kein WorkingDay
EndFunc ;==>_IsWorkingDay

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Funktion _Feiertage(\$Jahr)
;
; gibt die Feiertage des Ã¼bergebenen Jahres
; als sortiertes Array[TT.MM.JJJJ od. JJJJ/MM/TT][Feiertag][Geltungsbereich][opt. Wochentag] zurÃ¼ck
; Geltungsbereich Leerstring - kein offizieller Feiertag
; BG - Bundesweit Gesetzlich
; Regionalkennzeichen: BB-Brandenburg BE-Berlin BW-Baden-WÃ¼rttemberg BY-Bayern
; HB-Bremen HE-Hessen HH-Hamburg MV-Mecklenburg-Vorpommern
; NI-Niedersachsen NW-Nordrhein-Westfalen RP-Rheinland-Pfalz
; SH-Schleswig-Holstein SL-Saarland SN-Sachsen
; ST-Sachsen-Anhalt TH-ThÃ¼ringen
; \$vBundesland -1 alle Feiertage mit Geltungsbereich (BundeslÃ¤nder), (Standard)
; 0 BG nur Bundesweit gesetzlich
;
; Bundesland (inkl. BG)
; 1 SH Schleswig-Holstein
; 2 HH Freie und Hansestadt Hamburg
; 3 NI Niedersachsen
; 4 HB Freie Hansestadt Bremen
; 5 NW Nordrhein-Westfalen
; 6 HE Hessen
; 7 RP Rheinland-Pfalz
; 9 BY Bayern
; 10 SL Saarland
; 11 BE Berlin
; 12 BB Brandenburg
; 13 MV Mecklenburg-Vorpommern
; 14 SN Freistaat Sachsen|Sachsen
; 15 ST Sachsen-Anhalt
; 16 TH ThÃ¼ringen
; \$DateTyp 1 - Datum als TT.MM.JJJJ (Standard)
; 0 - Datum als JJJJ/MM/TT
; \$wDay 0 - geÃ¤ndert: RÃ¼ckabe Wochentag numerisch 1-7 / Sonntag-Samstag
; 1 - RÃ¼ckgabe Wochentag (\$array[n][3])
; \$sort 0 - gegliedert fix/variabel (Standard), innerhalb sortiert
; 1 - komplett sortiert
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func _Feiertage(\$year, \$vBundesland = -1, \$DateTyp = 1, \$wDay = 0, \$sort = 0)
Local \$HDays[33][4], \$a, \$b, \$c, \$d, \$e, \$H1, \$H2, \$n, \$M
Local \$aWDays[8] = [7, 'Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Sonnabend']
Local \$aBuLand[17] = ['BG', 'SH', 'HH', 'NI', 'HB', 'NW', 'HE', 'RP', 'BW', 'BY', 'SL', 'BE', 'BB', 'MV', 'SN', 'ST', 'TH']
If IsString(\$vBundesland) Then \$vBundesland = _ArraySearch(\$aBuLand, \$vBundesland)
;fixe Feiertage
\$HDays[0][0] = \$year & "/01/01\Neujahr\BG"
\$HDays[1][0] = \$year & "/01/06\Heilige Drei KÃ¶nige\BW BY ST"
\$HDays[2][0] = \$year & "/02/14\Valentinstag\"
\$HDays[3][0] = \$year & "/05/01\Maifeiertag\BG"
\$HDays[4][0] = \$year & "/08/15\MariÃ¤ Himmelfahrt\BY SL"
\$HDays[5][0] = \$year & "/10/03\Tag der Deutschen Einheit\BG"
\$HDays[6][0] = \$year & "/10/31\Reformationstag\BB MV SN ST TH"
\$HDays[7][0] = \$year & "/11/01\Allerheiligen\BW BY NW RP SL"
\$HDays[8][0] = \$year & "/12/24\Heiligabend\BG"
\$HDays[9][0] = \$year & "/12/25\1. Weihnachtsfeiertag\BG"
\$HDays[10][0] = \$year & "/12/26\2. Weihnachtsfeiertag\BG"
\$HDays[11][0] = \$year & "/12/31\Silvester\BG"
;variable Feiertage
\$a = Mod(\$year, 19)
\$b = Mod(\$year, 4)
\$c = Mod(\$year, 7)
\$H1 = Int(\$year / 100)
\$H2 = Int(\$year / 400)
\$n = 4 + \$H1 - \$H2
\$M = 15 + \$H1 - \$H2 - Floor(Int((8 * \$H1 + 13) / 25))
\$d = Mod((19 * \$a + \$M), 30)
\$e = Mod((2 * \$b + 4 * \$c + 6 * \$d + \$n), 7)
If \$d + \$e = 35 Then
\$Easter = 50
Else
If \$d = 28 And \$e = 6 And \$a > 10 Then
\$Easter = 49
Else
\$Easter = 22 + \$d + \$e
EndIf
EndIf
If \$Easter < 32 Then
\$EasterDay = \$Easter
\$EasterMonth = "03"
Else
\$EasterDay = \$Easter - 31
\$EasterMonth = "04"
EndIf
If \$EasterDay < 10 Then
\$EasterDay = "0" & \$EasterDay
EndIf
If \$year < 1900 Then ; Datumsoperationen nur mgl. wenn > 1900 , Jahr wird konvertiert
\$RestJahr = Mod(\$year, 100)
If _DateIsLeapYear(\$year) Then
If \$RestJahr < 10 Then
\$RestJahr = "0" & \$RestJahr
EndIf
\$Tempyear = 20 & \$RestJahr
Else
If \$RestJahr < 10 Then
\$RestJahr = "0" & \$RestJahr
EndIf
\$Tempyear = 19 & \$RestJahr
EndIf
\$EasterDate = \$Tempyear & "/" & \$EasterMonth & "/" & \$EasterDay
Else
\$EasterDate = \$year & "/" & \$EasterMonth & "/" & \$EasterDay
EndIf
\$OSoDat = \$EasterDate
; Ermitteln nicht von Ostern abhÃ¤ngiger, verÃ¤nderlicher Feiertage
; Muttertag = 2. Sonntag im Mai ABER wenn Pfingsten = 2.Sonntag im Mai dann ist Muttertag am 1. Sonntag
; Der 2. Sonntag kann nur zw. dem 8. u. 14.5. liegen
For \$maitag = 8 To 14
If _DateToDayOfWeek(\$year, 5, \$maitag) = 1 Then
If \$maitag < 10 Then
\$maitag = "0" & \$maitag
EndIf
\$MutterDat = \$year & "/05/" & \$maitag
If \$MutterDat = \$PfSoDat Then
\$MutterDat = _DateAdd('d', -7, \$year & "/05/" & \$maitag)
EndIf
ExitLoop
EndIf
Next
; Erntedankfest 1. Sonntag im Oktober (zw. 1. u. 7.10.)
For \$oktobertag = 1 To 7
If _DateToDayOfWeek(\$year, 10, \$oktobertag) = 1 Then
\$oktobertag = "0" & \$oktobertag
\$ErnteDat = \$year & "/10/" & \$oktobertag
ExitLoop
EndIf
Next
; 4.Advent = Sonntag vor 25.12. (zw. 18. u. 24.12.)
For \$deztag = 18 To 24
If _DateToDayOfWeek(\$year, 12, \$deztag) = 1 Then
\$4AdvDat = \$year & "/12/" & \$deztag
ExitLoop
EndIf
Next
\$HDays[12][0] = \$WFastDate & "\Weiberfastnacht\"
\$HDays[13][0] = \$RosDat & "\Rosenmontag\"
\$HDays[14][0] = \$FastDat & "\Fastnacht\"
\$HDays[15][0] = \$AschDat & "\Aschermittwoch\"
\$HDays[16][0] = \$GrDoDat & "\GrÃ¼ndonnerstag\"
\$HDays[17][0] = \$KarDat & "\Karfreitag\BG"
\$HDays[19][0] = \$OSoDat & "\Ostersonntag\"
\$HDays[20][0] = \$OMoDat & "\Ostermontag\BG"
\$HDays[21][0] = \$HiFaDat & "\Christi Himmelfahrt\BG"
\$HDays[22][0] = \$PfSoDat & "\Pfingstsonntag\"
\$HDays[23][0] = \$PfMoDat & "\Pfingstmontag\BG"
\$HDays[24][0] = \$MutterDat & "\Muttertag\"
\$HDays[25][0] = \$FroDat & "\Fronleichnam\BW BY HE NW RP SL SN TH"
\$HDays[26][0] = \$ErnteDat & "\Erntedankfest\"
\$HDays[27][0] = \$BuBDat & "\BuÃŸ- und Bettag\SN"
\$HDays[28][0] = \$TotSoDat & "\Totensonntag\"
If \$sort Then
_ArraySort(\$HDays)
Else
_ArraySort(\$HDays, 0, 0, 11)
_ArraySort(\$HDays, 0, 12)
EndIf
For \$i = 0 To 32
\$tmp = StringSplit(\$HDays[\$i][0], "\", 2)
If \$DateTyp Then ; Datum konvertieren zu TT.MM.JJJJ
\$HDays[\$i][0] = StringRight(\$tmp[0], 2) & "." & StringMid(\$tmp[0], 6, 2) & "." & StringLeft(\$tmp[0], 4)
Else
\$HDays[\$i][0] = \$tmp[0]
EndIf
\$HDays[\$i][1] = \$tmp[1]
\$HDays[\$i][2] = \$tmp[2]
If \$wDay = 1 Then
\$HDays[\$i][3] = \$aWDays[_DateToDayOfWeek(StringLeft(\$tmp[0], 4), StringMid(\$tmp[0], 6, 2), StringRight(\$tmp[0], 2))]
Else
\$HDays[\$i][3] = _DateToDayOfWeek(StringLeft(\$tmp[0], 4), StringMid(\$tmp[0], 6, 2), StringRight(\$tmp[0], 2))
EndIf
Next
If \$vBundesland > -1 Then
Local \$aTmp[1][4]
For \$i = 0 To 32
If StringInStr(\$HDays[\$i][2], \$aBuLand[\$vBundesland], 1) Or StringInStr(\$HDays[\$i][2], 'BG', 1) Then
If \$aTmp[UBound(\$aTmp) - 1][0] <> '' Then ReDim \$aTmp[UBound(\$aTmp) + 1][4]
\$aTmp[UBound(\$aTmp) - 1][0] = \$HDays[\$i][0]
\$aTmp[UBound(\$aTmp) - 1][1] = \$HDays[\$i][1]
\$aTmp[UBound(\$aTmp) - 1][2] = \$HDays[\$i][2]
\$aTmp[UBound(\$aTmp) - 1][3] = \$HDays[\$i][3]
EndIf
Next
Return \$aTmp
EndIf
Return \$HDays
EndFunc ;==>_Feiertage```

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-CafÃ© Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

##### Share on other sites

Hi Xeno,

Of course you're right, both day-of-week should be one less and it was supposed to be coded this way, else array indices will overflow array size for sunday dates! I have fixed the code posted above.

Ooops!

About the values in the array: I simply hardcoded them by simple count for row 0 then shifted and adjusted subsequent rows. I've tried to come up with a closed form formula but it's complexity far exceeds a dumb constant lookup like I used.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

Spudw.

Any the array? How you make?

Spoiler

Things I've Made: AOT Tool â—ŠÂ AU History â—ŠÂ Deck of Cards â—Š HideIt â—Š ICU â—Š Icon Freezer â—Š Ipod Ejector â—Š Link Downloader â—Š MD5 Folder Enumerator â—Š PassGen â—ŠÂ Ping Tool â—Š Quick NIC â—Š Read OCR â—Š RemoteIT â—Š SchTasksGui â—Š SpyCam â—Š â—Š Transparency MachineÂ
Misc Code Snippets: ADODB Example â—Š CheckHoverÂ â—ŠÂ Detect SafeMode â—Š DynEnumArray â—Š GetNetStatDataÂ â—Š HashArrayâ—Š Local Admins â—Š Make Choice â—Š Recursive File List â—Š
Projects: Drive Space Usage GUI â—ŠÂ LEDkIT â—Š Plasma_kIt â—ŠÂ Scan Engine Builder â—Š SpeeDBurner â—Š SubnetCalc
Cool Stuff:

Â

##### Share on other sites

See post edited above.

I had a use for actual worked days (excluding fixed and mobile hollydays [Easter-based]) but it's too specific to be of general use here.

Since I had to cover periods a bit longer than one year I had to take mobile hollydays for 2 years into account. I also had extra entries for days where the (variable) French post vans are prohibited to circulate, also for days on strike (!). I excluded those dates by dichotomy in the sorted hollydays array and counting dates being between date from and dateto.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites

... I also had extra entries for days where the (variable) French post vans are prohibited to circulate, also for days on strike (!).

Doesn't this returns the 'number of days left for school work' instead of 'number of days left before the end of the school year' ?

In this case you forgot in the extra entries the 'teachers absences due to illness'

##### Share on other sites

Not precisely. Its main use was for managing parcel tracking data and detecting obsolescence of parcels having experienced problems (lost, delayed beyond contract, damaged, not sent) while reimbursements were being claimed.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...