jimmilton

start time / end time

Discussion created by jimmilton on Feb 23, 2011
Latest reply on Feb 23, 2011 by charlie@osisoft.com

We have confused ourselves a little with when a timestamp is in UTC and when it is not.  If someone could clear this up for us, that would be great.

 

I have a little code: 

 

 

 
piro.UtcStartdate = Convert.ToDateTime(textBox3.Text).ToUniversalTime();
piro.UtcEndtime = Convert.ToDateTime(textBox4.Text).ToUniversalTime();

.....

NamedValues nValues = point.Data.Summaries(piro.UtcStartdate, piro.UtcEndtime,
                                                                            GetBoundrySetting(piro.SummaryType), GetSummaryType(piro.SummaryType),
                                                                            Convert.ToInt32(intv),
                                                   CalculationBasisConstants.cbTimeWeightedContinuous
                                                                            , null);

 

 

piro.UtcStartdate and piro.UtcEndtime are datetime objects.  Is the summaries function expecting datetime in local time or UTC?  If its expecting time in local, how do you specify first vs second Hour Ending 2 on the long day?  The timestamps that are returned, are they in UTC?

 

 

 
piro.CollectedData.Add(v.TimeStamp.LocalDate.AddSeconds(piro.IntervalSeconds).ToString(), Convert.ToDouble(v.Value.ToString()));

 

 

What I expect to do is to take a date time for start and end from the user, convert it to UTC, ask the PI server for the data in the UTC interval times, and get back a set of data with time in UTC.  Then I can choose to convert it to local time or to leave in UTC.  99% of the time we will want to leave it in UTC when we load it into another db server.  Only when we return it to a client do we want to have it in local time again, but that is very very rare.  

 

 

 

 

Outcomes