Counting the Dates



I'm trying to solve a problem in the most efficient way. I can solve this
problem, but my solution is turtle slow.

Say you have a file with 10 years of numerical values. One value per
calendar date, excluding weekends and holidays.

January 1, 1997 = 89
January 2, 1997 = 123
January 3, 1997 = 14
....
December 12, 2007 = 77


The first calendar date of the data file does not necessarily start with
January 1st of whatever year. It's likely not.

So you start reading the data file, adding up all the values that fall on
the same Month and Day of each year that you have in the file.

When done, you should have an array that has the total value for January 1,
2, 3, 4, 5, 6, 7... all the way to December 31.

In other words, if I have 10 years of data and my data file starts with
March 3rd 1997, I start by placing the value for March 3rd in an array
element, then the 4th, 5th, etc. When I get back to March 3rd of the next
year, this is added to the first March 3rd value and stored in the same
element number of the array.

So to start off with, I imagine I start by creating an array with 366
elements, one for every day of the year that includes the leap year?

I assume that I'd want to use Array(0) for all the January 1 and Array(365)
for all the December 31?

I'm curious if there is a simple way to read the date and quickly determine
what the array element would be.

Would I perhaps first create some sort of table reference, perhaps in a file
or by way of function, that uses MM/DD as the index and references numbers
from 0 to 365, so that each date that is read in would be compared to the
indexes of this table, the element number discovered, and then I'd know
where in my array to add the value to?

Am I making this more complicated than it should be? If you say no, I'd be
very surprised. :-o

Any suggestions or examples?

Thank you.

Webbiz

(In case I'm not making sense: I want to add up all the values found under
January 1 of each year and place them in the first array element. All the
values found under January 2nd of each year and place the total in the
second array element, etc.)



.



Relevant Pages

  • Re: Counting the Dates
    ... to you is to use a two-dimensional array instead of one. ... So you start reading the data file, adding up all the values that fall on ... (In case I'm not making sense: I want to add up all the values found ... under January 1 of each year and place them in the first array element. ...
    (microsoft.public.vb.general.discussion)
  • Re: Counting the Dates
    ... The other way to structure it, which bypasses the problem with leap years, but may or may not be useful to you is to use a two-dimensional array instead of one. ... So you start reading the data file, adding up all the values that fall on the same Month and Day of each year that you have in the file. ... In other words, if I have 10 years of data and my data file starts with March 3rd 1997, I start by placing the value for March 3rd in an array element, then the 4th, 5th, etc. ...
    (microsoft.public.vb.general.discussion)
  • Re: Base64-Encoding
    ... -- Pad input data to 3-Byte boundary. ... -- Overlay array of six-bit tokens over the padded input data. ... You're hoping for a representation of an array of 6-bit integers, ... the second array element is such that the two high ...
    (comp.lang.ada)
  • Re: Bugs at my web site
    ... "7.2.1.1.1 Array Element Successor Function and Value of a Subscript. ...
    (comp.lang.fortran)
  • Re: Counting the Dates
    ... calendar date, excluding weekends and holidays. ... So you start reading the data file, adding up all the values that fall on ... you should have an array that has the total value for January ... (In case I'm not making sense: I want to add up all the values found under ...
    (microsoft.public.vb.general.discussion)