goodmanjl531 Posted January 15, 2022 Share Posted January 15, 2022 I am trying to create a calendar generator I use a date control GUI to pick start date. I then need to add 6 days to get the last day of the week picked. Then i want to add a week to each to move week by week( I am assuming original date will be a sunday) part of my code... the msgbox with the $currentFYweekDTEnd shows a 0 then when i add the 2 dates at the end i get errors. so the _dateadd is not working right. Thanks in Advance for any and all help expandcollapse popup#include <date.au3> #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Form1_1 = GUICreate("Fiscal Year Builder", 385, 487, 285, 125) $Input_Fiscal_Year = GUICtrlCreateInput("YYYY", 191, 16, 78, 21) $Label1 = GUICtrlCreateLabel("Fiscal Year", 39, 16, 53, 17) $Group1 = GUICtrlCreateGroup("Weeks per QTR", 191, 224, 110, 97) $Radio1 = GUICtrlCreateRadio("4-5-4", 215, 248, 81, 25) GUICtrlSetState(-1, $GUI_CHECKED) $Radio2 = GUICtrlCreateRadio("4-5-5", 215, 288, 89, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("Weeks in Year", 23, 224, 110, 97) $Radio3 = GUICtrlCreateRadio("52", 39, 248, 65, 33) GUICtrlSetState(-1, $GUI_CHECKED) $Radio4 = GUICtrlCreateRadio("53", 39, 288, 65, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) $Date_FS = GUICtrlCreateDate("2022/01/01", 23, 96, 134, 105) $Button1 = GUICtrlCreateButton("Generate", 95, 344, 166, 81) $DATE_FE = GUICtrlCreateDate("2022/01/01", 191, 99, 134, 105) $Label2 = GUICtrlCreateLabel("Fiscal Start Date", 39, 56, 79, 17) $Label3 = GUICtrlCreateLabel("Fiscal End Date", 191, 56, 76, 17) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 createcalendar() EndSwitch wend Exit func createcalendar() $Fiscal_Year=GUICtrlRead($Input_Fiscal_Year) $weeks454=GUICtrlread($Radio1) $weeks455=GUICtrlRead($Radio2) $52weeks=GUICtrlRead($Radio3) $53weeks=GUICtrlRead($Radio4) $FYStart = GUICtrlRead($Date_FS) $FYEnd = GUICtrlRead($DATE_FE) If $weeks454 =1 then $weeks1=4 $weeks2=5 $weeks3=4 Else $weeks1=4 $weeks2=5 $weeks3=5 EndIf If $52weeks = 1 Then $TotalWeeks=52 Else $TotalWeeks=53 EndIf ;MAIn Counters $current_month=1 $current_Qtr=1 $current_week=1 $monthsInQtr=1 $CurrentWeekInMonth=1 $currentFYWeekDate=$FYStart $currentFYweekDTEnd=_DateAdd('d',6,$currentFYWeekDate) MsgBox(0,""," S Date:"& $currentFYWeekDate &@CRLF &"E DATE:"&$currentFYweekDTEnd) While $current_week <= $TotalWeeks Select Case $current_month = 1 or 4 or 7 or 10 $TotalWeekInMonth = $weeks1 Case $current_month = 2 or 5 or 8 or 11 $TotalWeekInMonth = $weeks2 Case $current_month = 3 or 6 or 9 or 12 $TotalWeekInMonth = $weeks3 EndSelect MsgBox(0,"","FY:" & $Fiscal_Year & @CRLF &"QTR:" & $current_Qtr & @CRLF & "Month:" & $current_month & @CRLF & "Week:" & $current_week & @CRLF & "Start date:" &$currentFYWeekDate & @CRLF & "End date: " & $currentFYweekDTEnd) $current_week = $current_week + 1 $CurrentWeekInMonth = $CurrentWeekInMonth+1 $currentFYWeekDate = _DateAdd('w',1,$currentFYWeekDate) $currentFYweekDTEnd= _DateAdd('w',1,$currentFYweekDTEnd) If $CurrentWeekInMonth > $TotalWeekInMonth Then $CurrentWeekInMonth=1 $current_month =$current_month +1 $monthsInQtr =$monthsInQtr + 1 EndIf If $monthsInQtr = 4 Then $current_Qtr =$current_Qtr +1 $monthsInQtr = 1 EndIf WEnd EndFunc Link to comment Share on other sites More sharing options...
Nine Posted January 15, 2022 Share Posted January 15, 2022 Did you check the @error code after _DateAdd ? Could help you know... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
goodmanjl531 Posted January 15, 2022 Author Share Posted January 15, 2022 i get error code 3 invalid date which is odd as the date before the function is a proper date Link to comment Share on other sites More sharing options...
Developers Jos Posted January 15, 2022 Developers Share Posted January 15, 2022 Are you sure the format of the Date is valid as defined in the helpfile? Show us the exact Date used for input. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
goodmanjl531 Posted January 15, 2022 Author Share Posted January 15, 2022 the input is pulled from the GUI $Date_FS = GUICtrlCreateDate("2022/01/01", 23, 96, 134, 105) $FYStart = GUICtrlRead($Date_FS) $currentFYWeekDate=$FYStart $currentFYweekDTEnd=_DateAdd('D',6,$currentFYWeekDate) Link to comment Share on other sites More sharing options...
Nine Posted January 15, 2022 Share Posted January 15, 2022 30 minutes ago, goodmanjl531 said: i get error code 3 invalid date which is odd Not so odd. You have to understand that date is not a variable type in AutoIt. All variables are variant and dates are consider as string. So there is multiple ways to save date field in a variable. You need to make sure your string follow the rule of the functions you rely on. goodmanjl531 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Solution goodmanjl531 Posted January 15, 2022 Author Solution Share Posted January 15, 2022 figured out the issue i changed to. $Date_FY_YearStart = GUICtrlCreateDate("2022/01/01", 23, 96, 134, 105)Local $sStyle = "yyyy/MM/dd" GUICtrlSendMsg($Date_FY_YearStart, $DTM_SETFORMATW, 0, $sStyle) and it works. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now