Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 sql

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-03-11 : 00:42:18
hemant writes "Hi,
i want to display all date and day in on month.
rgd,
hemant"

Nazim
A custom title

1408 Posts

Posted - 2002-03-11 : 02:43:13
you can try on these lines



create procedure monthdates (@mDate datetime)
as
set nocount on

declare @no int
declare @year int
declare @month int
declare @noofdays int
set @no=1

set @year=datepart(yyyy,@mdate)
set @month=datepart(mm,@mdate)
set @mdate=@mdate-datepart(dd,convert(datetime,@mdate+@no,121))+1


if @month=2
begin
if @year%4 =0
set @noofdays=29
else
set @noofdays=28
end
else if @month in (1,3,5,7,8,10,12)
set @noofdays=31
else
begin
set @noofdays=30
print 'test'
end

create table #tempd( mdate datetime)

while @no <= @noofdays

begin
insert into #tempd select convert(datetime,@mdate+@no,121)
set @no=@no+1
end
select * from #tempd
drop table #tempd
go

exec monthdates '11-dec-2002'


--------------------------------------------------------------
Go to Top of Page
   

- Advertisement -