SQL日期时间格式仅限日期

Ram*_*Ram 20 sql sql-server datetime sql-server-2005

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

SELECT Subject, DeliveryDate 
from Email_Administration 
where MerchantId =@ MerchantID
Run Code Online (Sandbox Code Playgroud)

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

非常感谢提前!:)

Mar*_*ith 29

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

select Subject, 
       CONVERT(varchar,DeliveryDate,101) as DeliveryDate
from Email_Administration 
where MerchantId =@MerchantID 
Run Code Online (Sandbox Code Playgroud)


小智 17

尝试以下操作,因为没有varchar转换

SELECT Subject, CAST(DeliveryDate AS DATE)
from Email_Administration 
where MerchantId =@ MerchantID
Run Code Online (Sandbox Code Playgroud)