Author |
|
andyR Newbie
Joined: April 07 2010
Online Status: Offline Posts: 15
|
Posted: December 21 2010 at 17:46 | IP Logged
|
|
|
I am trying to set up a timed event to happen once a month (i.e. on the first day of the month). I've crawled around the various forums, and have found how to create timed event formulas, but I'm having trouble getting the formula correct for once a month as opposed to something that happens as a multiple of 7 days. I've started with the July 4th example and changed it to:
datetime(date(xxxx, month(today()) + [INCREMENT],1), 00:00:00)
but am having trouble with what to put in the year part (xxxx above). At first I tried a simple 'year(today()) + [INCREMENT]' but I don't think that the internal INCREMENT variable can be used twice in one formula. I've also tried a couple of incantations with [REFTIME] in them without any success.
Is there an elegant way to do this, or will I have to create something more complicated that figures out how many days are in each month and then increments from that? Thanks in advance for any insight you are able to give me.
andyR
|
Back to Top |
|
|
dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 21 2010 at 21:34 | IP Logged
|
|
|
Andy,
The formula below will work for the first day of any month:
Code:
datetime(date(year(relativedate(today(),31)),1 + [INCREMENT],1),time([REFTIME])) |
|
|
As you can see, its pretty close to yours. You can use the [INCREMENT] more than once in a formula, but all instances will be the same value. The first time the formula is tested, [INCREMENT] will equal 0, the next test and [INCREMENT] (all instances in formula) will be 1. This will keep what you were hoping to do from working.
You are correct that you want the month to increment, but you also need a method to set the year. For months 1 thru 11, this will be the current year. In month 12, the relativedate will roll the year forward 1 giving you the increment you need.
If anyone wants to adapt this formula for a specific day of any month, just change the 1 between [INCREMENT] and [REFTIME] to the day number you want.
Hope this helps,
Dave.
|
Back to Top |
|
|
andyR Newbie
Joined: April 07 2010
Online Status: Offline Posts: 15
|
Posted: December 22 2010 at 20:56 | IP Logged
|
|
|
Thanks for the quick reply, Dave. I don't think I would have come up with the clever use of relativedate(....) to advance the year on my on. I have so much to learn about PH.... Thanks again.
andy
|
Back to Top |
|
|
|
|