Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SQL Server中获得今天的第一个小时?_Sql_Sql Server_Date_Datetime - Fatal编程技术网

如何在SQL Server中获得今天的第一个小时?

如何在SQL Server中获得今天的第一个小时?,sql,sql-server,date,datetime,Sql,Sql Server,Date,Datetime,我需要获得今天的日期,但不是当前时间,我需要日期的第一次 错误的方式: '4/7/2017 4:50:13 PM' 由于使用了getdate()函数 正确的方式: '4/7/2017 00:00:00 AM' 谢谢你的帮助这个怎么样 select cast(cast(getdate() as date) as datetime) 这个怎么样 select cast(cast(getdate() as date) as datetime) 选择Conver

我需要获得今天的日期,但不是当前时间,我需要日期的第一次

错误的方式:

'4/7/2017 4:50:13 PM' 
由于使用了
getdate()
函数

正确的方式:

'4/7/2017 00:00:00 AM'
谢谢你的帮助

这个怎么样

        select cast(cast(getdate() as date) as datetime)
这个怎么样

        select cast(cast(getdate() as date) as datetime)
选择Convert(varchar(max),getdate(),111)可能有效。使用您需要的varchar(无论什么)选择Convert(varchar(max),getdate(),111)可能可以工作。使用varchar(任何你需要的)