Sign in to follow this  
Followers 0
judgedk

_DateAdd function

6 posts in this topic

I tried severel things but cant get it to work.

$d1 = _NowCalcDate()
$M1 = _DateAdd("y" & "d", -1, $d1)

I know this dosent work, but i guess it says what i want to do.

Thanks

Share this post


Link to post
Share on other sites



I tried severel things but cant get it to work.

$d1 = _NowCalcDate()
$M1 = _DateAdd("y" & "d", -1, $d1)

I know this dosent work, but i guess it says what i want to do.

Thanks

#include <Date.au3>
$now = _NowCalcDate()
$add = _DateAdd("Y",-1,$now)
MsgBox(0,"DATE",$add)

When the words fail... music speaks

Share this post


Link to post
Share on other sites

#include <Date.au3>
$now = _NowCalcDate()
$add = _DateAdd("Y",-1,$now)
MsgBox(0,"DATE",$add)
Thanks for the reply.

But your examble gives today's date -1 on the year.

I need to -1 on the date and -1 on the year.

Thanks.

Share this post


Link to post
Share on other sites

Thanks for the reply.

But your examble gives today's date -1 on the year.

I need to -1 on the date and -1 on the year.

Thanks.

I think you have enough information now to work out what to do!

Your example didn't work, Adreik's example did what you describe, the help tells you to use one letter and you used 2.

So just do it in 2 steps. Reduce by one year then by one day.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

I think you have enough information now to work out what to do!

Your example didn't work, Adreik's example did what you describe, the help tells you to use one letter and you used 2.

So just do it in 2 steps. Reduce by one year then by one day.

As martin told you, you'll have to use two steps. Since AutoIt accepts nested function calls you could do:
$YearAndDayAgo = _DateAdd("D", -1, _DateAdd("Y", -1, _NowCalcDate()))

You might expect to be able to just do -366 days, but that will come out wrong for leap years.

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

As martin told you, you'll have to use two steps. Since AutoIt accepts nested function calls you could do:

$YearAndDayAgo = _DateAdd("D", -1, _DateAdd("Y", -1, _NowCalcDate()))

You might expect to be able to just do -366 days, but that will come out wrong for leap years.

:P

Thank you very much, been trying a lot of different things to get this working.. but not this :unsure:

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