Ever wondered how to define a period for the various Tag*xxx(x)* or other functions that take a start and end period. I have come up with a set of start and end periods that appear to work in a solution that I am implementing. I am keen to know if there are any better ways of setting these up. The weekly is an odd one, not sure how I worked that one out. With Weekly and on wards you need to consider your starting point, so weekly starts on a Monday at 00:00:00, etc.

**Hourly – Schedule hourly**

PeriodStart := 't'+Hour('*')*3600-3600

PeriodEnd := 't'+Hour('*')*3600

** **

**Daily- Schedule daily**

PeriodStart := 'y'

PeriodEnd := 't'

** **

**Weekly- Schedule daily**

NewPeriod := if Day('*')=2 then true else false

PeriodStart := if NewPeriod then 't'-(Weekday('*')+5)*86400 else NoOutput()

PeriodEnd := if NewPeriod then PeriodStart+7*86400 else NoOutput()

** **

**Monthly- Schedule daily**

NewPeriod := If Day('*')=1 then true else false

PeriodStart := Bom('*'-(day('*')+1)*86400)

PeriodEnd := Bonm(PeriodStart)

**Quarterly- Schedule daily**

NewPeriod := if (Month('*')=1 or Month('*')=4 or Month('*')=7 or Month('*')=10) and Day('*')=1 then true else false

PeriodStart := if NewPeriod=true then 't-3mo'-(Day('*-3mo')-1)*3600*24 else NoOutput()

PeriodEnd := if NewPeriod then 't'-(Day('*')-1)*3600*24 else NoOutput()

**Yearly- Schedule daily**

NewPeriod := if Month('*')=1 and Day('*')=1 then true else false

PeriodStart := if NewPeriod then 't-12mo' else NoOutput()

PeriodEnd := if NewPeriod then 't'else NoOutput()

I have just seen the error of my ways...

The period calcs are fine, but as they can only be scheduled daily they do not need to be separate analyses, they could all be encapsulated in one with the appropriate if's for related code.

I guess it helps to think aloud :¬)