小编典典

如何在SQL Server中获取当前/今天的日期数据

sql

如何编写查询以获取今天的日期数据SQL server

select * from tbl_name where date = <Todays_date>

阅读 461

收藏
2021-03-23

共1个答案

小编典典

正确答案将取决于您的确切类型datecolumn。假设它是类型Date

select * from tbl_name 
where datecolumn = cast(getdate() as Date)

如果是DateTime

select * from tbl_name 
where cast(datecolumn as Date) = cast(getdate() as Date)
2021-03-23