motormad 0 Posted October 23, 2010 Can sombody help me out with the syntx for a date format. I would like the day in 2 digits - month in 2 digits - year in 4 digits. Somthing like. msgbox (day(now()) & month(now()) & year(now)) ) ?? I cant find it. Share this post Link to post Share on other sites
HavikTech 0 Posted October 23, 2010 _NowDate() _DateTimeFormat() _StringReplace() StringRegExpReplace() Share this post Link to post Share on other sites
UEZ 1,277 Posted October 23, 2010 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
motormad 0 Posted October 23, 2010 (edited) 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 ? Edited October 23, 2010 by motormad Share this post Link to post Share on other sites
GEOSoft 67 Posted October 23, 2010 MsgBox(0, "Date", StringFormat("%02d", @MDAY) & "-" & StringFormat("%02d", @MON) & "-" & @YEAR) Br, UEZ Even simpler MsgBox(0, "Date", StringFormat("%02d-%02d-%d", @MDAY, @MON, @YEAR)) GeorgeQuestion 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!" Share this post Link to post Share on other sites
GEOSoft 67 Posted October 23, 2010 Thanx UEZIt 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? GeorgeQuestion 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!" Share this post Link to post Share on other sites
motormad 0 Posted October 23, 2010 (edited) Nice but... How do i get my date in it. Lets say 20-04-2010 ? Thanks for you fast replys $MonthCal1 = GUICtrlCreateMonthCal("2010/10/21", 442, 50, 169, 158) Edited October 23, 2010 by motormad Share this post Link to post Share on other sites
UEZ 1,277 Posted October 23, 2010 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
GEOSoft 67 Posted October 23, 2010 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 GeorgeQuestion 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!" Share this post Link to post Share on other sites
Bowmore 97 Posted October 23, 2010 (edited) 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 October 23, 2010 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 Share this post Link to post Share on other sites
motormad 0 Posted October 24, 2010 Yes Thats it thanx Also i will use Opt('MustDeclareVars', 1) In the future and learn more about StringRegExpReplace Share this post Link to post Share on other sites
motormad 0 Posted October 24, 2010 (edited) 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 October 24, 2010 by motormad Share this post Link to post Share on other sites
UEZ 1,277 Posted October 24, 2010 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Share this post Link to post Share on other sites
BigDod 518 Posted October 24, 2010 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 Share this post Link to post Share on other sites
motormad 0 Posted October 24, 2010 Thank you all people it works fine now Share this post Link to post Share on other sites