henryd Posted July 12, 2009 Share Posted July 12, 2009 Hi I am new to autoit3.I am able to retrieve the system date and time to a variable by using "_Date_Time_GetLocalTime()" but I wish to retrieve only the date and save it to a variable which i will user later in the code. Link to comment Share on other sites More sharing options...
Yargo Posted July 12, 2009 Share Posted July 12, 2009 HiI am new to autoit3.I am able to retrieve the system date and time to a variable by using "_Date_Time_GetLocalTime()"but I wish to retrieve only the date and save it to a variable which i will user later in the code.Local $currentDate=@MDAY & @MON & @YEARYou may play with it as you need. E.G.: Local $currentDate=@YEAR & "_" & @MON & "_" & @MDAYHTH,Yaron Golan blemas 1 Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 12, 2009 Share Posted July 12, 2009 There is also Function _NowDate_NowDate and _Function _DateTimeFormat_DateTimeFormat. Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 (edited) There is also Function _NowDate_NowDate and _Function _DateTimeFormat_DateTimeFormat. I tried _nowdate but it only displays the current date this is what i want to do 1) get current system date and save to a variable x 2)change date 3) run program 4) change date back to earlier date by calling x this is the code. I am able to change date using _setdate but I can't seem to store current date to variable( see line 4 and 9 ) and then restore it back. #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> $CurrDate =_NowDate() $tNewDate = _SetDate(21, 8, 2009) Run("file.xls") WinWaitActive("file") WinWaitClose("file") _SetDate($CurrDate) Edited July 12, 2009 by henryd Link to comment Share on other sites More sharing options...
trancexx Posted July 12, 2009 Share Posted July 12, 2009 I tried _nowdate but it only displays the current date this is what i want to do 1) get current system date and save to a variable x 2)change date 3) run program 4) change date back to earlier date by calling x this is the code. I am able to change date using _setdate but I can't seem to store current date to variable( see line 5 ) and then restore it back #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> $CurrDate =_NowDate() $tNewDate = _SetDate(21, 8, 2009) Run("file.xls") WinWaitActive("file") WinWaitClose("file") _SetDate($CurrDate) Line 5 is empty line ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 Doesn't make any difference..I removed the empty line Link to comment Share on other sites More sharing options...
trancexx Posted July 12, 2009 Share Posted July 12, 2009 Doesn't make any difference..I removed the empty line I does. It's not empty now. See this: ; #FUNCTION# ==================================================================================== ; Name...........: _SetDate ; Description ...: Sets the current date of the system ; Syntax.........: _SetDate($iDay[, $iMonth = 0[, $iYear = 0]]) ; Parameters ....: $iDay - Day of the month. Values: 1-31 ; $iMonth - Optional: month. Values: 1-12 ; $iYear - Optional: year. Values: > 0 (windows might restrict this further!!) ; Return values .: Success - 1 ; Failure - 0 ; @Error - 0 - No error. ; |1 - Failure ; @extended - GetLastError() ; |Error code(s): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp ; Author ........: /dev/null ; Modified.......: ; Remarks .......: If the optional parameters (iMonth,iYear) are NOT defined, the function will not change the current value! ; Related .......: _SetTime ; Link ..........; ; Example .......; Yes ; ======================================================================================================= ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 (edited) I does. It's not empty now. See this: ; #FUNCTION# ==================================================================================== ; Name...........: _SetDate ; Description ...: Sets the current date of the system ; Syntax.........: _SetDate($iDay[, $iMonth = 0[, $iYear = 0]]) ; Parameters ....: $iDay - Day of the month. Values: 1-31 ; $iMonth - Optional: month. Values: 1-12 ; $iYear - Optional: year. Values: > 0 (windows might restrict this further!!) ; Return values .: Success - 1 ; Failure - 0 ; @Error - 0 - No error. ; |1 - Failure ; @extended - GetLastError() ; |Error code(s): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/debug/base/system_error_codes.asp ; Author ........: /dev/null ; Modified.......: ; Remarks .......: If the optional parameters (iMonth,iYear) are NOT defined, the function will not change the current value! ; Related .......: _SetTime ; Link ..........; ; Example .......; Yes ; ======================================================================================================= hmm..ok my syntax was wrong in the last line...but then how do u revert back to the previous date ? Edited July 12, 2009 by henryd Link to comment Share on other sites More sharing options...
trancexx Posted July 12, 2009 Share Posted July 12, 2009 hmm..ok my syntax was wrong in the last line...but then how do u revert back to the previous date ?AAhhh... you edited. Nice timing. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 I used a different approach ..almost succeeded.. I am able to change date and revert back to the old date after closing the file. But in this case it reverts back to the previous time as well. I only want to revert back to the previous date when the file closes #include <GuiConstantsEx.au3> #include <Date.au3> #include <WindowsConstants.au3> $tCur = _Date_Time_GetLocalTime() $tNew = _Date_Time_EncodeSystemTime(8, 29, 2009,@HOUR,@MIN,@SEC) _Date_Time_SetLocalTime(DllStructGetPtr($tNew)) Run("file.xls") WinWaitActive("file") WinWaitClose("file") _Date_Time_SetLocalTime(DllStructGetPtr($tCur)) Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 any suggestions.plz Link to comment Share on other sites More sharing options...
trancexx Posted July 12, 2009 Share Posted July 12, 2009 My rep will probably go down again but... Use you brain. You can't see the forest for the trees. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
henryd Posted July 12, 2009 Author Share Posted July 12, 2009 @tranceex If u don't know the solution just shut up ! Nobody's forcing you to even reply Get a life..a gf even.. If u had even an ounce of Grey matter in your head...u better know whats next. Link to comment Share on other sites More sharing options...
trancexx Posted July 12, 2009 Share Posted July 12, 2009 @tranceexIf u don't know the solution just shut up ! Nobody's forcing you to even replyGet a life..a gf even..If u had even an ounce of Grey matter in your head...u better know whats next.Ok, I'll try but I'm not making any promises.Education is very important. <- yes, it's a link ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now