Jump to content

_DateAdd function


Recommended Posts

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.

Link to comment
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.

Link to comment
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.
Link to comment
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
Link to comment
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:
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...