SQL datetime格式仅限于日期 [英] SQL datetime format to date only

查看:160
本文介绍了SQL datetime格式仅限于日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从sql数据库中选择DeliveryDate作为日期。在数据库中,我将其保存为日期时间格式。如何获得日期?

  SELECT Subject,DeliveryDate 
from Email_Administration
其中MerchantId = @ MerchantID

03/06/2011 12:00:00刚刚被选为03/06 / 2011 ..



提前谢谢! :

解决方案

在仔细阅读以前的问题之后,我最终确定你可能在SQL Server 2005上。对于美国格式,您将使用样式101

  select Subject,
CONVERT(varchar,DeliveryDate,101)as DeliveryDate
from Email_Administration
其中MerchantId = @ MerchantID
/ pre>

I am trying to select the DeliveryDate from sql database as just date. In the database, i am saving it as datetime format. How is it possible to get just date??

SELECT Subject, DeliveryDate 
from Email_Administration 
where MerchantId =@ MerchantID

03/06/2011 12:00:00 Am just be selected as 03/06/2011..

Thanks alot in advance! :)

解决方案

After perusing your previous questions I eventually determined you are probably on SQL Server 2005. For US format you would use style 101

select Subject, 
       CONVERT(varchar,DeliveryDate,101) as DeliveryDate
from Email_Administration 
where MerchantId =@MerchantID 

这篇关于SQL datetime格式仅限于日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆