SQl查询日期 [英] SQl query for date
本文介绍了SQl查询日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在sql 2008中仅从datetime中提取日期
请指定除convert
how to extract only date from datetime in sql 2008
please specify any other method except convert
推荐答案
以外的其他方法
http: //www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-Date-Time-Stamp-in-SQL-Server.htm [
Have a look here
http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm[^]
e.g
SELECT
CAST( FLOOR( CAST( getDate() AS FLOAT ) ) AS DATETIME )
Dylan已经给了您完美的答案,您也可以使用给定的代码来从DateTime获取日期
Dylan already given you Perfect answer you can also use given code to get Date from DateTime
select Dateadd(dd,0,datediff(dd,0,getdate()))
它有效
试试吧.
it works
try it..
这篇关于SQl查询日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文