Jump to content

Recommended Posts

Posted (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 by ur
Posted

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.

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
×
×
  • Create New...