Jump to content

Trying to Get Yesterdays date into GuiBox


Recommended Posts

Hi,

I made this little example, when i run this it shows todays date in the gui box.

When i try to do a msgbox with $YD is shows the correct date.

But when i put $YD in this $date1 = GUICtrlCreateDate($YD, 10, 10, 80, 20) it wont work..

Thank You for any Comments .

#include <GUIConstants.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>

Local $DTM_SETFORMAT_, $style



$YD = @YEAR&"/"&@MON&"/"&@MDAY-1
$LY = @YEAR-1&"/"&@MON&"/"&@MDAY

MsgBox(0, "", $YD)


$Form1 = GUICreate("Form1", 366, 235, 193, 115)
$date1 = GUICtrlCreateDate($YD, 10, 10, 80, 20)
$date2 = GUICtrlCreateDate($LY, 10, 50, 80, 20)
$Button1 = GUICtrlCreateButton("Button1", 136, 192, 89, 33, 0)
GUISetState(@SW_SHOW)

$style = "dd.MM.yyyy"
$DTM_SETFORMAT_ = 0x1032
GUICtrlSendMsg($date1, $DTM_SETFORMAT_, 0, $style)
GUICtrlSendMsg($date2, $DTM_SETFORMAT_, 0, $style)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _ok()

EndSwitch
 
WEnd
func _ok()
    
    $1 = GUICtrlRead($date1)
    MsgBox(0, "Time", $1)
        
    $2 = GUICtrlRead($date2)
    MsgBox(0, "Time", $2)
    
EndFunc
Link to comment
Share on other sites

#include <GUIConstants.au3>
#include <Date.au3>
#include <DateTimeConstants.au3>

Local $DTM_SETFORMAT_, $style

$DTM_SETFORMAT_ = 0x1032
    
$YD   = @YEAR&"/"&@MON&"/0"&@MDAY-1
$LY = @YEAR-1&"/"&@MON&"/"&@MDAY

MsgBox(0, "", $YD)
MsgBox(0, "", $LY)


$Form1 = GUICreate("Form1", 366, 235, 193, 115)
$date1 = GUICtrlCreateDate($YD, 10, 10, 100, 20)
$date2 = GUICtrlCreateDate($LY, 10, 50, 100, 20)
$Button1 = GUICtrlCreateButton("Button1", 136, 192, 89, 33, 0)
GUISetState(@SW_SHOW)

$style = "dd/MM/yyyy"
GUICtrlSendMsg($date1, $DTM_SETFORMAT_, 0, $style)
GUICtrlSendMsg($date2, $DTM_SETFORMAT_, 0, $style)
GUICtrlSetData ($date1, $YD)
GUICtrlSetData ($date2, $LY)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            _ok()

EndSwitch

WEnd
func _ok()
    
    $1 = GUICtrlRead($date1)
    MsgBox(0, "Time", $1)
        
    $2 = GUICtrlRead($date2)
    MsgBox(0, "Time", $2)
    
EndFunc

Does that work?

Link to comment
Share on other sites

Yes, thank you.

This works.

I see u made this change

$YD = @YEAR&"/"&@MON&"/0"&@MDAY-1

Does that have any effect on the date when it comes to the 11.12.13 and so on?

I'm at work right now so i cant change this computers date, so i have to ask ...

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...