Jump to content
Sign in to follow this  
noobieautolearn

_DateAdd

Recommended Posts

noobieautolearn
Posted (edited)

The issue I'm having seems relatively straight forward, but I've run into an issue an I wonder if there is a work around. 

 

If I run the code below I get : ==> Variable cannot be accessed in this manner.:

#include <Date.au3>

$sDateTime = "2016/01/31 23:00:00"

$sDateTime2 = _DateAdd('d', 1, $sDateTime())

MsgBox($MB_SYSTEMMODAL, "", "Date: " & $sDateTime2)

 

If I run the code below it works.

#include <Date.au3>

$sDateTime2 = _DateAdd('d', 1, "2016/01/31 23:00:00"())

MsgBox($MB_SYSTEMMODAL, "", "Date: " & $sDateTime2)

Is there a work around for this? I want to take a date that is stored in a variable from earlier in the script and add a day to it.

Edited by noobieautolearn

Share this post


Link to post
Share on other sites
JLogan3o13

Your first one will work if you take the () out after $sDateTime. It is a variable, not a function.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
noobieautolearn
40 minutes ago, JLogan3o13 said:

Your first one will work if you take the () out after $sDateTime. It is a variable, not a function.

Interesting, thank you very much that worked, I appreciate it.  Why then does it work when you have the () after the date and time in the second example?

Share this post


Link to post
Share on other sites
JLogan3o13

Your second example did not work for me, until I took the () out. What version of AutoIt, and what version of Windows, are you using?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
noobieautolearn
17 hours ago, JLogan3o13 said:

Your second example did not work for me, until I took the () out. What version of AutoIt, and what version of Windows, are you using?

That is strange, I got it to work running by running it in SciTE-Lite go using the tools then go option. I have SciTE-Lite version Version 3.5.4 .

Share this post


Link to post
Share on other sites
JLogan3o13

Which makes sense, as Scite-Lite would not perform the AU3Check syntax check before running.


√-1 2^3 ∑ π, and it was delicious!

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  

×