Number Of Days
-
how can i calculate the number of days in the current month in MS SQL Server 2000. can any body help me, no matter wether usage of Stored Proc, or any other code, i am sick of working on it. FIRE
-
how can i calculate the number of days in the current month in MS SQL Server 2000. can any body help me, no matter wether usage of Stored Proc, or any other code, i am sick of working on it. FIRE
This will do it. DECLARE @MonthInt int DECLARE @YearInt int DECLARE @TempVarChar varchar(30) DECLARE @Mth_Start datetime DECLARE @Mth_End datetime DECLARE @DaysInMonth int SET @MonthInt = 08 SET @YearInt = 2005 -- GET START NEXT MONTH START IN Char Set @TempVarChar = '01/' + CAST(@MonthInt As Varchar(2) ) + '/' + CAST(@YearInt As Varchar(4) ) -- Convert to Date Set @Mth_Start = (Convert( datetime, @TempVarChar, 103 )) -- Go Back one day to get last day in Month. Set @Mth_End = DATEADD( dd, -1, @Mth_Start) -- Get total days in Month SET @DaysInMonth = DATEPART(dd, @Mth_end) SELECT @DaysInMonth