Thread Subject: daylight savings adjustment

Subject: daylight savings adjustment

From: Steve

Date: 1 Aug, 2007 17:52:42

Message: 1 of 4

I have several years' worth of hourly data in Excel. Times are given and they take into account daylight saving. How can I locate all of the time data that is affected by daylight saving (as of 2007, it starts at 2:00 AM on the second Sunday in March and ends at 2:00 AM on the first Sunday in November) and subtract one hour from the values?

This one has stumped me for a while now. Any help is appreciated. Thanks!

Subject: daylight savings adjustment

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 1 Aug, 2007 18:21:46

Message: 2 of 4

In article <f8qh9a$l69$1@fred.mathworks.com>,
Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
>I have several years' worth of hourly data in Excel. Times are given
>and they take into account daylight saving. How can I locate all of
>the time data that is affected by daylight saving (as of 2007, it
>starts at 2:00 AM on the second Sunday in March and ends at 2:00 AM on
>the first Sunday in November) and subtract one hour from the values?

How are the times encoded?

datenum and datevec might be of assistance.
--
  "law -- it's a commodity"
                         -- Andrew Ryan (The Globe and Mail, 2005/11/26)

Subject: daylight savings adjustment

From: Steve

Date: 1 Aug, 2007 18:45:25

Message: 3 of 4

The dates are in Excel as 'd/m/yyyy'. I transferred to Matlab and converted as follows:

------

[datanum datatxt dataraw]=xlsread('filename');

dates=datatxt(3:end,1); %These are of form 'd/m/yyyy'

tdst=cell2mat(dataraw(3:end,2))*24; %Converts times from form '3:00 PM' to form '15'

------

Now I need to take the 'tdst' values (daylight saving times) and subtract 1 - but only between the dates/times 2:00 AM on the second Sunday in March and 2:00 AM on the first Sunday in November. The problem is that these datenums change, and so I'm currently trying to hunt down the dates using something like

for time=t'
march{time}=calendar(year(time),3);
november{time}=calendar(year(time),11);
startDSTloc=march(find(min(march(:,1)>0))+1,1);
endDSTloc=november(find(min(november(:,1)>0)),1);
end

Then I'd somehow specifiy tstd=tdst-1 only for tdst between '3/march(startDSTloc,1)/year 2:00AM' and '11/november(endDSTloc,1)/year 2:00AM'.

Any suggestions? Thanks.

roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) wrote in message <f8qivq$dlm$1@canopus.cc.umanitoba.ca>...
> In article <f8qh9a$l69$1@fred.mathworks.com>,
> Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:
> >I have several years' worth of hourly data in Excel. Times are given
> >and they take into account daylight saving. How can I locate all of
> >the time data that is affected by daylight saving (as of 2007, it
> >starts at 2:00 AM on the second Sunday in March and ends at 2:00 AM on
> >the first Sunday in November) and subtract one hour from the values?
>
> How are the times encoded?
>
> datenum and datevec might be of assistance.
> --
> "law -- it's a commodity"
> -- Andrew Ryan (The Globe and Mail, 2005/11/26)

Subject: daylight savings adjustment

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 1 Aug, 2007 19:14:41

Message: 4 of 4

In article <f8qkc5$pka$1@fred.mathworks.com>,
Steve <steveDEL.bachmeierDEL@yahoo.com> wrote:

>Now I need to take the 'tdst' values (daylight saving times) and
>subtract 1 - but only between the dates/times 2:00 AM on the second
>Sunday in March and 2:00 AM on the first Sunday in November. The
>problem is that these datenums change, and so I'm currently trying to
hunt down the dates using something like

>for time=t'
>march{time}=calendar(year(time),3);
>november{time}=calendar(year(time),11);
>startDSTloc=march(find(min(march(:,1)>0))+1,1);
>endDSTloc=november(find(min(november(:,1)>0)),1);
>end

I'm not sure what t is here, and I suspect you want startDSTloc
and endDSTloc to be indexed by {time} . And since you are going
over multiple years, you need to take into account that the rules
changed this year.

>Then I'd somehow specifiy tstd=tdst-1 only for tdst between '3/march(startDSTloc,1)/year 2:00AM' and '11/november(endDSTloc,1)/year 2:00AM'.

Once you have figured out the appropriate start and stop times,
datenum() them, and then the positions that need to be changed
are the ones whose datenum() fall between the two values.
--
  "law -- it's a commodity"
                         -- Andrew Ryan (The Globe and Mail, 2005/11/26)

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
datenum Steve 1 Aug, 2007 13:55:05
calendar Steve 1 Aug, 2007 13:55:05
time Steve 1 Aug, 2007 13:55:05
datevec Steve 1 Aug, 2007 13:55:05
date Steve 1 Aug, 2007 13:55:05
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com