Billing cycle and energy consumption query

I’m logging energy consumption so that I can query my historian for peak or max energy use. I know how to write the query to get peak value out of the data base. The problem is that the billing cycle doesn’t start on the first of the month. In fact the cycle varies from the 9th, 10th or 11th based on the month. What I want to have happen is to have the operator select the month and year from a calendar object and I set the proper date range and run the query. For Example Oct 12 has a billing range of 9/3/12 to 10/29/12

Thanks

Are you storing the data using SQLTags Historian, or some other method (Transaction groups, 3rd party, etc…)?
What database are you using?

If it’s stored in the through transaction groups or something similar, you’ll need a query that looks between two date ranges. In MySQL your query binding would look something like this:

SELECT * FROM table WHERE t_stamp BETWEEN time1 AND time2

Where time1 and time2 can be references to the date property of calendar components on your screen somewhere.

The attached file shows a year’s billing cycle. So what I want to do is when the operator selects July of 2011, I automatically set “time 1” to 7/11/2011 and” time 2” to 8/9/2011 and run my query. So the calendar needs to trigger a start and stop date lookup.
Thanks for the help

I’d make a dropdown list that has a dataset that looks just like the one you created up above. Then have custom properties that represent a start date and an end date, and bind them to the proper columns from the selected option. Hope this helps, talk to you later.