Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create a View with every day of the month, programmatically in SQL

Posted on 2006-11-03
1
Medium Priority
?
843 Views
Last Modified: 2010-10-05
Experts,

I've got a table that shows Begin_Date, End_Date, Exchange_Rate.  The rate may change weekly.

I'd like to create a view that lists every day of the month, with the exchange rate shown for that day.

Can you think of a way, in using SQL code, I can SELECT every day of the month, and link it to my Exchange Rate table?
0
Comment
Question by:AptDev
1 Comment
 
LVL 10

Accepted Solution

by:
AaronAbend earned 2000 total points
ID: 17870191

declare @adate datetime
declare @monthno int
begin

set @adate='11/01/2006' - seed with a date
set @monthno = datepart(mm,@adate)

while (datepart(mm,@adate)=@monthno)
  begin
  select exchangerate from table1 where adate=@adate
  set @adate=dateadd(d, 1, @adate)

  end
end

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have a large data set and a SSIS package. How can I load this file in multi threading?
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question