Wie schon erwähnt, werde ich diese Funktion bald mehrmals gebrauchen.
Will Sie euch deshalb nicht vorenthalten. Sicher nichts spezielles aber vielleicht brauchbar.
UDF:
[autoit]
#include <Date.au3>
#include <String.au3>
#include <Array.au3>
#cs ----------------------------------------------------------------------------
[/autoit][autoit][/autoit][autoit]AutoIt Version: 3.3.0.0
Author: Gianni
UDF Function:
[/autoit][autoit][/autoit][autoit]#ce ----------------------------------------------------------------------------
[/autoit][autoit][/autoit][autoit]Func _getFirstDayMonth ($date)
Local $MyDate, $MyTime, $RDate, $dateDay[2]
$date = _StringExplode($date, ".")
$date = String($date[2] & "/" & $date[1] & "/" & $date[0])
_DateTimeSplit($date, $MyDate, $MyTime)
$dateDayAdd = _DateAdd('D', - $MyDate[3] + 1, $date)
_DateTimeSplit($dateDayAdd, $RDate, $MyTime)
$dateToDay = _DateToDayOfWeek($RDate[1], $RDate[2], $RDate[3])
$dateDay[1] = _DateDayOfWeek($dateToDay)
$dateDayAdd = _StringExplode($dateDayAdd, "/")
$dateDay[0] = String($dateDayAdd[2] & "." & $dateDayAdd[1] & "." & $dateDayAdd[0])
Return $dateDay
EndFunc
Func _getLastDayMonth ($date)
Local $MyDate, $MyTime, $RDate, $dateDay[2]
$date = _StringExplode($date, ".")
$date = String($date[2] & "/" & $date[1] & "/" & $date[0])
_DateTimeSplit($date, $MyDate, $MyTime)
$calc = _DateAdd('M', 1, $date)
$dateDayAdd = _DateAdd("D", - $MyDate[3], $calc)
_DateTimeSplit($calc, $RDate, $MyTime)
$dateToDay = _DateToDayOfWeek($RDate[1], $RDate[2], $RDate[3])
$dateDay[1] = _DateDayOfWeek($dateToDay)
$dateDayAdd = _StringExplode($dateDayAdd, "/")
$dateDay[0] = String($dateDayAdd[2] & "." & $dateDayAdd[1] & "." & $dateDayAdd[0])
Return $dateDay
EndFunc
und hier ein beispiel dazu:
[autoit]
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <_firstLastDay.au3>
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Gianni
Script Function:
[/autoit][autoit][/autoit][autoit]#ce ----------------------------------------------------------------------------
[/autoit][autoit][/autoit][autoit]; Script Start - Add your code below here
[/autoit][autoit][/autoit][autoit][/autoit][autoit]#Region ### START Koda GUI section ### Form=D:\Programmierung\AutoIt\FistLastMonth\fldForm.kxf
$fldForm = GUICreate("FirstLastDay", 372, 210, 202, 125)
GUISetFont(10, 800, 0, "Arial")
$labelDatum = GUICtrlCreateLabel("Date (dd.mm.yyyy)", 24, 32, 133, 20)
$inputDatum = GUICtrlCreateInput("", 168, 32, 121, 24)
$btnCalc = GUICtrlCreateButton("Calc", 136, 80, 75, 25, 0)
$fstinMonth = GUICtrlCreateLabel("First Day in Month", 24, 128, 118, 20)
$lstInMonth = GUICtrlCreateLabel("Last Day in Month", 232, 128, 117, 20)
$labelFDate = GUICtrlCreateLabel("Date", 48, 152, 70, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$labelFDay = GUICtrlCreateLabel("Day", 48, 176, 70, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$labelLastDate = GUICtrlCreateLabel("Date", 256, 152, 70, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
$labelLastDay = GUICtrlCreateLabel("Day", 256, 176, 70, 19)
GUICtrlSetFont(-1, 9, 400, 0, "Arial")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnCalc
$readDate = GUICtrlRead($inputDatum)
If $readDate <> "" And StringRegExp($readDate, '..........') Then
$getFirstDate = _getFirstDayMonth($readDate)
$getLastDate = _getLastDayMonth ($readDate)
GUICtrlSetData($labelFDate, $getFirstDate[0])
GuiCtrlSetData($labelFDay, $getFirstDate[1])
GUICtrlSetData($labelLastDate, $getLastDate[0])
GuiCtrlSetData($labelLastDay, $getLastDate[1])
Else
MsgBox(0, "Attention", "Please insert Date")
EndIf
EndSwitch
WEnd
grüsse
Gianni