Home All Groups Group Topic Archive Search About

Increment thru dates



Author
16 Nov 2006 6:59 PM
juya
Hi all,

I have a clearly simple question. I just need to iterate thru dates
that are passed as parameters - From date and end date. I need to
execute the following code that currently loops. I am not exactly sure
where I need to put the date loop. Any help pls.

The parameters are here -

@From date datetime
@end date datetime

open store_t
fetch next from store_t into @store_no
--Loop through each Store
while @@fetch_status = 0
begin
    print @store_no
    exec dbo.Export @store_no,@order_date
    exec dbo.Prod_Export @store_no,@order_date
    fetch next from store_t into @store_no
end
close st
deallocate st

Author
16 Nov 2006 7:32 PM
Edgardo Valdez, MCTS, MCITP, MCSD, MCDBA
If I understand correctly, you can populate a table variable with the dates:
@dates(one per day) starting from the @from_date and ending on the @end_date.
Then loop through the @dates table variable and execute the code you posted
inside of it.


Show quoteHide quote
"juya" wrote:

> Hi all,
>
> I have a clearly simple question. I just need to iterate thru dates
> that are passed as parameters - From date and end date. I need to
> execute the following code that currently loops. I am not exactly sure
> where I need to put the date loop. Any help pls.
>
> The parameters are here -
>
> @From date datetime
>  @end date datetime
>
> open store_t
> fetch next from store_t into @store_no
> --Loop through each Store
> while @@fetch_status = 0
> begin
>     print @store_no
>     exec dbo.Export @store_no,@order_date
>     exec dbo.Prod_Export @store_no,@order_date
>     fetch next from store_t into @store_no
> end
> close st
> deallocate st
>
>

Bookmark and Share