返回错误结果的日期范围之间的SQL
我正在编写一个SQL查询,以获取日期范围格式之间的行:mm/dd/yyyy 我使用了返回错误结果的日期范围之间的SQL,sql,sql-server,Sql,Sql Server,我正在编写一个SQL查询,以获取日期范围格式之间的行:mm/dd/yyyy 我使用了between操作符,但结果显示日期超出范围 Select Internship_StartDate1 From [Media_BPM].[dbo].[BP_UGME] Where TrainingType = 'Medical Internship Training' and Internship_StartDate1 Between '01/%/2020%' AND '06/%/2020%' Order
between
操作符,但结果显示日期超出范围
Select Internship_StartDate1
From [Media_BPM].[dbo].[BP_UGME]
Where TrainingType = 'Medical Internship Training'
and Internship_StartDate1 Between '01/%/2020%' AND '06/%/2020%'
Order By Internship_StartDate1 desc
预期结果:仅限2020年的日期
实际结果是:
实习\u开始日期1
05/16/2018
05/06/2018
05/05/2019
05/05/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/02/2019
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2020
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2019
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2018
05/01/2017
04/30/2018
04/29/2018
04/18/2018
04/14/2017
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2020
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2019
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2018
04/01/2017
04/01/2017
04/01/2017
04/01/2017
03/19/2019
03/18/2018
03/04/2018
03/03/2019
03/03/2019
03/03/2019
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2020
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
03/01/2019
Select Internship_StartDate1
from [Media_BPM].[dbo].[BP_UGME]
where TrainingType = 'Medical Internship Training'
AND FORMAT(Internship_StartDate1, 'yyyyMM') Between '202001' AND '202006'
Order By Internship_StartDate1 desc
SELECT Internship_StartDate1 from [Media_BPM].[dbo].[BP_UGME]
WHERE TrainingType = 'Medical Internship Training'
AND YEAR(CONVERT(date, Internship_StartDate1,103)) BETWEEN '2019' AND '2020'
ORDER BY Internship_StartDate1 desc
select Internship_StartDate1
from [Media_BPM].[dbo].[BP_UGME]
where TrainingType = 'Medical Internship Training' and
Internship_StartDate1 >= '2020-01-01' and
Internship_StartDate1 < '2020-07-01'
order by Internship_StartDate1 desc;
select Internship_StartDate1
from Media_BPM.dbo.BP_UGME
where TrainingType = 'Medical Internship Training' and
-- first and last time tick in 2020
Internship_StartDate1 between '20200101' and '20201231 23:59:59.997'
order by Internship_StartDate1 desc