Quantcast
Viewing all articles
Browse latest Browse all 20

Looping Problem

 

I am running a loop that calculates information on stocks.  It is set up a little bit like this:

- Run sql to read a starting row for stock data depending on what he input date is

- the program then loops for a certain number of days performing calculations and comparisons compared to that starting date.  When the desired information is found, it starts on the next date and continues to run.

 

The problem i am having is that i am using a variable, say LoopDate, which has 1 day added to it every time it loops so it is LoopDate.AddDays(1).

 

When this loop runs, since it just adds 1 to the date, it tries to pull information from weekends or holidays, even though they do not exist in the database.  This causes two problems. The first is that it attempts to run calculations on that day, but since there is no information in the database, it copies the most recent data (usually friday's of that week) and then calculates it.  This throws off the number of days that the calculation is running for (which is important) as well as the caclulated total.

 

I know this may sound confusing, i can clarify further if needed, but does anyone have any idea how i can get the calculator to only run for the days in the database while still being able to speicify how long it loops for?


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>