Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display weeks between 2 dates

Status
Not open for further replies.

saravananpk

Programmer
Jul 20, 2002
8
IN
hi,

how to display all the weeks between 2 input dates.
for ex. if start date is 12/03/2002 and end date is 14/06/2002, i need to display all the weeks starting from
12/03/2002. the output should be,
12/03/2002,18/03/2002,25/03/2002 etc. till end date.


sa.
 
Hi,
try this code snippit.it will satisfy ur requirement.

set nocount on
declare @startdate datetime,
@enddate datetime

set @startdate = convert(datetime,'03/12/2002')
set @enddate = convert(datetime,'06/14/2002')

create table #temp( weekdate datetime)
while @startdate<=@enddate
begin
insert into #temp values(@startdate)
set @startdate =@startdate+7
end
select convert(nvarchar(10),weekdate,101) as weekdate from #temp
drop table #temp
set nocount off P.Madhana Gopal,
Principal Software Engineer,
LCube Innovative Solns. Pvt. Ltd.,
India.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top