本文介绍了如何在sqlserver表中获取两个日期之间的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在sqlserver表中获取两个日期之间的记录?



此查询运行正常 -

选择Jobtitle,来自JobForm的CONVERT(varchar(10),CreatedDate,103),其中GETDATE() - 30和GETDATE()之间的CreatedDate



并返回适当的结果



但这不是错误 -



当我运行此查询时 -



How to get record between two two dates in sqlserver table ??

this query is running fine --
select Jobtitle ,CONVERT(varchar(10),CreatedDate,103) from JobForm where CreatedDate between GETDATE()-30 and GETDATE()

and returning appropriate result

but this is NOT whats the error --

when i am running this query --

select JobTitle, CONVERT(VARCHAR(11),CreatedDate,103)  from JobForm
    where CreatedDate between CONVERT(VARCHAR(11),'06/03/2013',103) and  CONVERT(VARCHAR(11),'09/02/2013',103)







我得到了没有记录,只有空白结果




I am getting no record ,just blank result

推荐答案


CONVERT(VARCHAR(11), CreateDate, 103)

我建议您将SQL更改为

I suggest you change your SQL to

SELECT JobTitle, CONVERT(VARCHAR(11),CreatedDate,103)  FROM JobForm
    WHERE CreatedDate BETWEEN  CONVERT(DATE,'09/02/2013',103) AND  CONVERT(DATE,'06/03/2013',103)





问候,



Regards,



这篇关于如何在sqlserver表中获取两个日期之间的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 00:07