dhoward Admin Group
Joined: June 29 2001 Location: United States
Online Status: Offline Posts: 4447
|
Posted: December 10 2004 at 14:50 | IP Logged
|
|
|
Nick,
There are a couple of ways you can do this.
You could create a timed event with a "Reference Time" of 11/27/2004 with a yearly frequency. The "Frequency" field has dropdown selections for common frequencies but you can type any frequency in minutes. There are 60 minutes in an hour, 24 hours in a day, 365 days a year for a frequency of 525600. You could then have the action of the timed event set a global variable for you. You could then also create a similar timed event for 01/03/2005 with a yearly frequency of 525600 to turn the variable "off". While this would work, leap years would throw this off a day.
The second way to do this would be to have a timed event that executes daily. I have one that executes everyday at 00:30. I have it call my "DAILY MACRO" which then in turn calculates whatever needs to be done on a daily basis. You could have a couple of lines that check the current date and if it's greater than or equal to 11/27 then turn the variable on or if it's greater than or equal to 01/03 then turn the variable off. This could be boiled down the formula below. This formula assumes you have a global variable called "CHRISTMAS" and will be set to 1 between 11/27 and 01/03 and 0 outside of that range:
ph_setglobal_a("CHRISTMAS",if(today() > date(string(year(today())) + "-11-27") or today() < date(string(year(today())) + "-01-03"),1,0))
It may be a little hard to follow, but if you take the time and think about how the date checking is done, you'll see that it makes sense.
Let me know if you need more help or I didnt answer it right.
Dave.
|