SQL Server Get only Date form column with Date and Time
This question already has an answer here:
Just use Cast
;
Select cast(BDATE as Date) BDATE from PersonData
Also, you can use Convert
function
Select convert(Date,BDATE) BDATE from PersonData
If you don't want special conversation styles, I suggest you to use Cast
instead of Convert
for simple type conversations.
You can use this.
SELECT CONVERT(VARCHAR(10), BDATE , 120) from PersonData
style : 120 for ODBC canonical yyyy-mm-dd hh:mi:ss(24h)
你可以像这样使用FORMAT:
SELECT FORMAT([BDATE],'yyy-MM-dd') AS 'BDATE' FROM PersonData;
链接地址: http://www.djcxy.com/p/94394.html
上一篇: 如何在SQL中选择没有时间的日期