如何在SQL中选择没有时间的日期 [英] How to select date without time in SQL
本文介绍了如何在SQL中选择没有时间的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在 SQL 中选择日期时,它返回为 2011-02-25 21:17:33.933
.但我只需要日期部分,即 2011-02-25
.我该怎么做?
When I select date in SQL it is returned as 2011-02-25 21:17:33.933
. But I need only the Date part, that is 2011-02-25
. How can I do this?
推荐答案
我猜他想要一个字符串.
I guess he wants a string.
select convert(varchar(10), '2011-02-25 21:17:33.933', 120)
这里的 120 告诉转换函数我们在 以下格式:yyyy-mm-dd hh:mi:ss
.
120 here tells the convert function that we pass the input date in the following format: yyyy-mm-dd hh:mi:ss
.
这篇关于如何在SQL中选择没有时间的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文