Jump to content

Date Formats


 Share

Recommended Posts

MsgBox(0, "Date", StringFormat("%02d", @MDAY) & "-" & StringFormat("%02d", @MON) & "-" & @YEAR)

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

MsgBox(0, "Date", StringFormat("%02d", @MDAY) & "-" & StringFormat("%02d", @MON) & "-" & @YEAR)

Br,

UEZ

Even simpler

MsgBox(0, "Date", StringFormat("%02d-%02d-%d", @MDAY, @MON, @YEAR))

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Thanx UEZ

It works but...

How do i get a specific date in the msgbox?

GUICtrlRead($MonthCal1)

the '$MonthCal1' is my date var.

How do i get my '$MonthCal1' date in @MDAY ?

What is $MonthCal1 actually returning? Can you give us an example?

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

You mean this:

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $Date, $msg
    GUICreate("Get date", 210, 190)

    $Date = GUICtrlCreateMonthCal("1953/03/25", 10, 10)
    GUISetState()

    ; Run the GUI until the dialog is closed or timeout

    Do
        $msg = GUIGetMsg()
        If $msg = $Date Then MsgBox(0, "debug", "calendar clicked")
    Until $msg = $GUI_EVENT_CLOSE

    MsgBox(0, $msg, StringRegExpReplace(GUICtrlRead($Date), "(\d+)/(\d+)/(\d+)", "$3-$2-$1"), 2)
EndFunc ;==>Example

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Or another example that still uses StringFormat()

GUICreate("Date Test")

$hdate = GUICtrlCreateDate("2010/10/21", 20,20, 100, 20, 0x00)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $hdate

            $aDate = StringSplit(GUICtrlRead($hdate), "/")
            MsgBox(0, "Date", StringFormat("%02d-%02d-%d", $adate[2], $adate[1], $adate[3]))
    EndSwitch
WEnd

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

If you are going to use the drop-down calendar to select a date you set it to return the selected date in the format you want directly

#include <GuiDateTimePicker.au3>

    $hGui = GUICreate("Date Test")

    $hdate = GUICtrlCreateDate("2010/10/21", 20,20, 100, 20, 0x00)
    $hWndDate = ControlGetHandle($hGui, "", $hdate)
    _GUICtrlDTP_SetFormat($hWndDate, "dd-MM-yyyy")
    GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $hdate
            MsgBox(0, "Selected Date", GUICtrlRead($hdate))
    EndSwitch
WEnd

Another example

#include <GuiDateTimePicker.au3>

    $hGui = GUICreate("Date Test")

    $hdate = GUICtrlCreateDate("2010/10/21", 20,20, 100, 20, 0x00)
    $hWndDate = ControlGetHandle($hGui, "", $hdate)
    _GUICtrlDTP_SetFormat($hWndDate, "dddd dd-MMMM-yyyy")
    GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case -3
            Exit
        Case $hdate
            MsgBox(0, "Selected Date", GUICtrlRead($hdate))
    EndSwitch
WEnd

Edit: added second example

Edited by Bowmore

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Yes Bowmore.

I think its the best way because you handle the problem in the beginning.

But ... I dont understand it ;)

ALso... now i have to send 29102010 in the program and not 29-10-2010

How do i do that.

I try whit

StringRegExpReplace(GUICtrlRead($aSTA[1]), "(\d+)/(\d+)/(\d+)", "$3$2$1"))
in the place of
StringRegExpReplace(GUICtrlRead($aSTA[1]), "(\d+)/(\d+)/(\d+)", "$3-$2-$1"))

the GUICtrlRead($aSTA[1]) is the value with 29-10-2010 in it

but it wont work.

Edited by motormad
Link to comment
Share on other sites

With my example above the line

MsgBox(0, $msg, StringRegExpReplace(GUICtrlRead($Date), "(\d+)/(\d+)/(\d+)", "$3$2$1"), 2)

is working as you want -> ddmmyyy

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Yes Bowmore.

I think its the best way because you handle the problem in the beginning.

But ... I dont understand it ;)

ALso... now i have to send 29102010 in the program and not 29-10-2010

How do i do that.

I try whit

StringRegExpReplace(GUICtrlRead($aSTA[1]), "(\d+)/(\d+)/(\d+)", "$3$2$1"))
in the place of
StringRegExpReplace(GUICtrlRead($aSTA[1]), "(\d+)/(\d+)/(\d+)", "$3-$2-$1"))

the GUICtrlRead($aSTA[1]) is the value with 29-10-2010 in it

but it wont work.

StringRegExpReplace(GUICtrlRead($aSTA[1]), "-", ""))


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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...