Table : Orders
where orderdate between 2016-06-01 and 2016-06-30
I think you are missing
' when specifying the date range. Also, you need to cast
DATE. The reason is because if you have data like '2016-06-30 12:34:56',
BETWEEN '2016-06-01' and '2016-06-30' will not return the record.
Select orderid from Orders where CONVERT(DATE, orderdate) between '2016-06-01' and '2016-06-30'