Learn T-SQL Commands with Samples
Skip Navigation Links
Skip Navigation Links.
Expand DatabaseDatabase
Expand TableTable
Expand ViewView
Expand Stored ProcedureStored Procedure
Expand Data FilteringData Filtering
Expand Data GroupingData Grouping
Expand JoinsJoins
Expand TriggerTrigger
Expand CursorCursor
Expand OperatorsOperators
Expand ConstraintsConstraints
Expand FunctionsFunctions
Expand Conditional ProcessingConditional Processing
Expand LoopingLooping
Expand Error HandlingError Handling
Collapse v.IMP Queriesv.IMP Queries
Expand XMLXML
Expand Query PerformanceQuery Performance
Expand QueriesQueries
Expand NormalizationNormalization
Expand CreateCreate
     

Find Data Between Two Dates

 
      
EMP
Name DOB
Vijay 1980-01-01 00:00:00
Bill 1980-06-06 00:00:00
Kris 1980-10-10 00:00:00
---- How to Find Rows Between Two Dates
DECLARE @startDate datetime SET @startDate = '4/4/1980' SELECT * FROM EMP_bwDate WHERE DOB between @startDate and '7/7/1980'
---- or
SELECT * FROM EMP_bwDate WHERE DOB between @startDate AND DATEADD(mm, 3, @startDate)
---- or
SELECT * FROM EMP_bwDate WHERE DOB >= @startDate AND DOB < DATEADD(mm, 3, @startDate)
Output
Name DOB
Bill 1980-06-06 00:00:00