today + 1 month onliner Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

today + 1 month onliner

Post by jkeks » 17 Jan 2023, 02:42

how to get today date + 1 month..

code

Code: Select all

  todayPlusMonth = %A_Now%
  EnvAdd, todayPlusMonth, 30, Days
  FormatTime, todayPlusMonth,%todayPlusMonth%, dd.MM.yyyy
  Send, %todayPlusMonth%
is too hard and long, may it be onlines ?

Rohwedder
Posts: 7771
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: today + 1 month onliner  Topic is solved

Post by Rohwedder » 17 Jan 2023, 03:43

Hallo,
one line? Then try:

Code: Select all

#Requires AutoHotkey v2.0-
Send FormatTime(DateAdd(A_Now, 30, "Days"), "dd.MM.yyyy")
or shorter as your version:

Code: Select all

todayPlusMonth += 30, Days
FormatTime, todayPlusMonth,%todayPlusMonth%, dd.MM.yyyy
Send, %todayPlusMonth%
or:

Code: Select all

TPM += 30, Days
Send,% SubStr(TPM,7,2) "." SubStr(TPM,5,2) "." SubStr(TPM,1,4)
But correct solutions for 1 month later these are all not!

Better:

Code: Select all

Send,% SubStr(A_Now,7,2) "." Format("{:02}",Max(1,M:=Mod(SubStr(A_Now,5,2)+1,13))) "." SubStr(A_Now,1,4)+!M

jkeks
Posts: 60
Joined: 20 Oct 2019, 00:24
Contact:

Re: today + 1 month onliner

Post by jkeks » 17 Jan 2023, 05:17

Cool !, but most coolest is in AutoHotKeys 2 ))

Post Reply

Return to “Ask for Help (v1)”