Create procedure [dbo].[CountTotalDays] ( @StartDate DATETIME = null, @EndDate DATETIME = null , @StartDatePresent varchar(10) = 'Full Day',--- Full Day or Half Day @EndDatePresent varchar(10) = 'Full Day' --- Full Day or Half Day --SET @StartDate = '2015/11/07' --SET @EndDate = '2015/11/14' ) as begin Select [Days] = (DATEDIFF(dd, @StartDate, @EndDate) + 1) -(DATEDIFF(wk, @StartDate, @EndDate)... Continue Reading →
Find Second Last Record.
Select TOP 1 * from IdeaMaster where IdeaId not in ( select top ((select count(*) from IdeaMaster) - 2) IdeaId from IdeaMaster )
Using Set Operators.
---- Using Set Operators. ---- Union, Union ALL, Intersect, Except drop table #Temp1 drop table #Temp2 Create table #Temp1 ( ID int , name varchar(50) ) Insert into #Temp1 Values(1,'AAA') Insert into #Temp1 Values(2,'BBB') Insert into #Temp1 Values(3,'CCC') Insert into #Temp1 Values(4,'GGG') Insert into #Temp1 Values(5,'MMM') Create table #Temp2 ( ID int , name varchar(50)... Continue Reading →
Find out the Leave day from Working Days.
To Find out the Leave day from Working Days. Here is mentioned in Example, Start date and End date is counted as Half Day / Full Day each Respectively. DECLARE @StartDate DATETIME, @Sday int , @Tday int DECLARE @EndDate DATETIME DECLARE @StartDatePresent varchar(10) = 'Half Day' --- Full Day or Half Day DECLARE @EndDatePresent varchar(10)... Continue Reading →