Jump to content

Get Date Syntax


Recommended Posts

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

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.

Local $currentDate=@MDAY & @MON & @YEAR

You may play with it as you need. E.G.:

Local $currentDate=@YEAR & "_" & @MON & "_" & @MDAY

HTH,

Yaron Golan

Link to comment
Share on other sites

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

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 by henryd
Link to comment
Share on other sites

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

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

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 by henryd
Link to comment
Share on other sites

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

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