Sign in to follow this  
Followers 0
henryd

Get Date Syntax

14 posts in this topic

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.

Share this post


Link to post
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

1 person likes this

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by henryd

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Doesn't make any difference..I removed the empty line

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by henryd

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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))

Share this post


Link to post
Share on other sites

any suggestions.plz

Share this post


Link to post
Share on other sites

My rep will probably go down again but...

Use you brain.

You can't see the forest for the trees.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Ok, I'll try but I'm not making any promises.

Education is very important. <- yes, it's a link


♡♡♡

.

eMyvnE

Share this post


Link to post
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
Sign in to follow this  
Followers 0