Gui DateTime + add 7 days to selected date

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Johana
Posts: 189
Joined: 02 May 2017, 02:34

Gui DateTime + add 7 days to selected date

21 Jun 2017, 14:28

This is basically a two part question:
1: I am using gui DateTime in a box and then displaying the var with SendInput, %var%. However, it's sending a full date with current time. I tried to follow the help section stating i could use a custom date so i tried:

Gui, 1: Add, DateTime, vMyDate, yyyy-MM-dd

It didn't work. I tried to format time with:

Formattime, Mydate, , yyyy-mm-dd

And that didnt help either. What am I missing?

Part 2 of the question:

In one of the datetime guis I want to add a week to the selected date. I tried

Mydate +:= 7

But that didn't work either. What am I doing wrong?

Thanks!

Johana, Sweden.
GEV
Posts: 1002
Joined: 25 Feb 2014, 00:50

Re: Gui DateTime + add 7 days to selected date

21 Jun 2017, 15:42

Try

Code: Select all

Gui, 1: Add, DateTime, vMyDate, %A_Year%-%A_MM%-%A_DD%
Gui, 1: Show
or:

Code: Select all

Formattime, Mydate,, yyyy-mm-dd 
Gui, 1: Add, DateTime, vMyDate, %Mydate%
Gui, 1: Show
and

Code: Select all

today := A_Now
FormatTime, Mydate, %today%, yyyy-MM-dd
today += 7, days
FormatTime, after7days, %today%, yyyy-MM-dd

MsgBox today:`n%Mydate%`n`nafter 7 days:`n%after7days%
Johana
Posts: 189
Joined: 02 May 2017, 02:34

Re: Gui DateTime + add 7 days to selected date

24 Jun 2017, 12:36

Thanks but none of that worked.

I tried this:

Code: Select all

today := A_Now
FormatTime, Mydate, %today%, yyyy-MM-dd
today += 7, days
FormatTime, after7days, %today%, yyyy-MM-dd

Formattime, Mydate,, yyyy-mm-dd
#NoEnv
Gui, 1:Add, DropDownList, vDropDownList1 R2 choose1 gToggle, X1|X2
Gui, 1:Add, DropDownList, vDropDownList2 R2 choose1 gToggle, y1|y2
Gui, 1: Add, DateTime, vStartingDate
Gui, 1: Add, DateTime, vMyDate, %MyDate%
Gui, 1:Add, text,, My text1
Gui, 1:Add, edit, vtext1
Gui, 1:Add, text,, My text2
Gui, 1:Add, edit, vtext2
Gui, 1:Add, text, vtX1Y2 Hidden, My text that shows when X1, Y2 is picked
Gui, 1:Add, edit, vX1Y2 Hidden
Gui, 1:Add, Button, gOK Default ,OK
Return

Toggle:
    Gui, 1: Submit, NoHide
    
    If (DropDownList1 = "X1") && (DropDownList2 = "y2") {
        GuiControl, 1: Show, X1Y2
        GuiControl, 1: Show, tX1Y2
    } Else {
        GuiControl, 1: Hide, X1Y2
        GuiControl, 1: Hide, tX1Y2
    } 
return

OK:
Gui, 1:Submit,NoHide
if (dropdownlist1 = "x1") && (dropdownlist2 = "y1")
{
MsgBox, The %text1% told the rabbit about %text2% and the date is %MyDate% and after 7 days %after7days%
exitapp
}
else if (dropdownlist1 = "x1") && (dropdownlist2 = "y2")
{
MsgBox, The %text1% told the rabbit about %text2% and %x1y2%
exitapp
}
;Gui 1: hide
return

#j::
Gui 1: show,, DropDownGui
return
And I tried to add your 2 other suggestions to no avail. It's still displaying the complete date with hhmmtt
see image: http://imgur.com/JejZ1k4

When using

Code: Select all

Gui, 1: Add, DateTime, vMyDate, %A_Year%-%A_MM%-%A_DD%
it's not letting me pick other dates in the calendar.

Any more suggestions?
GEV wrote:Try

Code: Select all

Gui, 1: Add, DateTime, vMyDate, %A_Year%-%A_MM%-%A_DD%
Gui, 1: Show
or:

Code: Select all

Formattime, Mydate,, yyyy-mm-dd 
Gui, 1: Add, DateTime, vMyDate, %Mydate%
Gui, 1: Show
and

Code: Select all

today := A_Now
FormatTime, Mydate, %today%, yyyy-MM-dd
today += 7, days
FormatTime, after7days, %today%, yyyy-MM-dd

MsgBox today:`n%Mydate%`n`nafter 7 days:`n%after7days%

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: cjsmile999, doodles333, Google [Bot], Lamron750 and 337 guests