Share via

Add between date and a specific date

Christopher Jack 1,616 Reputation points
2021-06-02T10:13:19.52+00:00

Hi,

In one of our feed I need to add between date and also a specific date

WHERE
sof.Sales_Office = @SalesOffice
and
s.postage = 'Y'
and
s.[Order Date] >= @FromDate and s.[Order Date] <= @ToDate

How would I say the above and s.[Order Date] = '02/06/2017'

Thanks for help.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

Answer accepted by question author

Olaf Helper 47,621 Reputation points
2021-06-02T10:40:43.277+00:00

If you want to get data for a specific date addtional to the date range, then it's a OR logic, not AND; don't forget the brackets =>

WHERE sof.Sales_Office = @SalesOffice
ands.postage = 'Y'
and (s.[Order Date] >= @FromDate and s.[Order Date] <= @ToDate 
     OR s.[Order Date] = '02/06/2017')

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.