Minus date not working correctly

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
rdonald18
Posts: 2
Joined: 15 Apr 2024, 19:59

Minus date not working correctly

15 Apr 2024, 20:03

Hello,

I have the below script that takes 31 days off the current date. This works fine the first time, but the second time takes 62, third time 93 etc. How do I stop this??

Code: Select all

::.td3::
DateMinus31 += -31,days
FormatTime, FormattedDate1, %DateMinus31%, dd-MM-yyyy
FormatTime, CurrentDateTime,, dd-MM-yyyy
    SendInput, %FormattedDate1%{tab}%CurrentDateTime%{Enter}
    Return
User avatar
boiler
Posts: 16996
Joined: 21 Dec 2014, 02:44

Re: Minus date not working correctly

15 Apr 2024, 20:10

The += operator adds to the previous value, so it keeps adding -31 to its previous value. Precede that line with DateMinus31 := A_Now so that it starts with today’s date each time.
rdonald18
Posts: 2
Joined: 15 Apr 2024, 19:59

Re: Minus date not working correctly

17 Apr 2024, 02:44

boiler wrote:
15 Apr 2024, 20:10
The += operator adds to the previous value, so it keeps adding -31 to its previous value. Precede that line with DateMinus31 := A_Now so that it starts with today’s date each time.
Thankyou so much boiler. That works perfectly now.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: IfThenElse, lechat, LuckyJoe, osail and 259 guests