ur Posted December 3, 2020 Posted December 3, 2020 (edited) My system time on windows 10 taskbar is showing in this format (12/3/2020) date/month/year format. I am picking a date of expiry field from UI using below function on my form. Local $Input2 = GUICtrlCreateDate("", 88, 40, 161, 21) Then, I am checking how many days left using below code. Func checkValidDays($sDate) ;MsgBox(0,"", _NowCalcDate()) ;$days_finished = _DateDiff('D',"2020-11-23",_NowCalcDate()) $days_finished = _DateDiff('D',$sDate,_NowCalcDate()) CreateResult("Expiry Date: "&$sDate) CreateResult("Today Date: "&_NowCalcDate()) CreateResult("Days finished: "&$days_finished) if $days_finished > 0 Then ;MsgBox($MB_ICONERROR,"","Date expired!!") Return False Else ;MsgBox($MB_ICONINFORMATION,"","Still "& Abs($days_finished) & " left.") Return True EndIf EndFunc It was expected to display date expired, but still running the else part. Execution of tool.exe Expiry Date: Monday, November 30, 2020 Execution of tool.exe Today Date: 2020/12/03 Execution of tool.exe Days finished: 0 ;To log the end output to a result file Func CreateResult($sResult="completed..") if FileExists(@ScriptDir&"\Logging.log") Then FileWrite(@ScriptDir&"\Logging.log","Execution of "& @ScriptName & " " & $sResult&@CRLF) FileMove(@ScriptDir&"\Logging.log",@ScriptDir&"\Results.txt",$FC_OVERWRITE+$FC_CREATEPATH ) ;FileDelete(@ScriptDir&"\Logging.log") ;FileCopy(@ScriptDir&"\Results.txt",@ScriptDir&"\Results_copy.txt",$FC_OVERWRITE+$FC_CREATEPATH ) else FileWrite(@ScriptDir&"\Results.txt","Execution of "& @ScriptName & " " & $sResult&@CRLF) EndIf EndFunc Please suggest. Edited December 3, 2020 by ur
Nine Posted December 3, 2020 Posted December 3, 2020 Your $sDate is obviously badly formatted. Change its format to fit _DateDiff required format (YYYY/MM/DD). “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) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ur Posted December 3, 2020 Author Posted December 3, 2020 that is by default set to this format only. yyyy/mm/dd https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateDate.htm Even I tried setting it like this but same result
GokAy Posted December 3, 2020 Posted December 3, 2020 Hey, According to function page default is (-1) : $DTS_LONGDATEFORMAT, which is what your output shows Execution of tool.exe Expiry Date: Monday, November 30, 2020 Tried this flag? $DTS_SHORTDATEFORMAT 0x00 Displays the date in short format. The default format string for this style is defined by LOCALE_SSHORTDATE, which produces output like "4/19/96". If that doesn't give what you want, maybe change system locale short date/time format to fit.
ur Posted December 3, 2020 Author Posted December 3, 2020 (edited) Yeah this seems to be working. I will try on multiple timezones and check. Local $Input2 = GUICtrlCreateDate("", 88, 40, 161, 21) ; to select a specific default format Local $sStyle = "yyyy/MM/dd" GUICtrlSendMsg($Input2, $DTM_SETFORMATW, 0, $sStyle) Edited December 3, 2020 by ur
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