how to use between in sql server 2008 r2

how to use between in sql server 2008 r2

The given below code-sample might help you to using BETWEEN keyword in SQL Server.

ALTER PROCEDURE [dbo].[getContractExpiration]
(
  @TenantID INT
 ,@CompanyID INT  = null
 ,@ExpDays INT
)
AS
BEGIN
SELECT COM.Name as CompanyName,
            C.NAME,
            SC.ContractID,
            SC.INSTALLATIONDATE,
            SC.STARTDATE,
            SC.ENDDATE   
       FROM CONTRACT  C
       INNER JOIN SERVICECONTRACT SC ON SC.CONTRACTID = C.ID
       INNER JOIN COMPANY COM ON COM.ID = C.CompanyID
       
       WHERE C.TENANTID =@TenantID
       AND  C.COMPANYID=ISNULL(@CompanyID, C.CompanyID)
       AND  SC.EndDate BETWEEN GETDATE() and GETDATE()+ @ExpDays
END 


ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
My Blogs - http://www.code-sample.com and http://www.code-sample.xyz
My Books - Google Amazon and Flipkart Book Store!

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.
ASK Questions
SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book