Counting the Dates
- From: "Webbiz" <noreply@xxxxxxx>
- Date: Sat, 26 Jan 2008 22:49:02 -0600
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.)
.
- Follow-Ups:
- Re: Counting the Dates
- From: Steve Gerrard
- Re: Counting the Dates
- From: Ralph
- Re: Counting the Dates
- From: Larry Serflaten
- Re: Counting the Dates
- From: Rick Rothstein \(MVP - VB\)
- Re: Counting the Dates
- From: Robert Morley
- Re: Counting the Dates
- From: Steve Gerrard
- Re: Counting the Dates
- Prev by Date: Re: determining is a file is open.....
- Next by Date: Re: Life of VB6?
- Previous by thread: Anyone care to comment on a thread ?
- Next by thread: Re: Counting the Dates
- Index(es):
Relevant Pages
|