将“date”从SQL Server中的DateTime字段中取出 [英] Getting the 'date' out of a DateTime field in SQL Server

查看:128
本文介绍了将“date”从SQL Server中的DateTime字段中取出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个日期列,日期显示格式为 2009-11-18 10:55:28.370

I have a date column where the date is displayed in the format 2009-11-18 10:55:28.370.

我只是希望得到这个值的日期(而不是时间)。如何做到这一点?

I just want to get the date (not time) out of that value. How do I do that?

推荐答案

如果您使用SQL Server 2008,现在有一个DATE数据类型。使它更自然!

If you're using SQL Server 2008, there is now a DATE datatype. Makes it a lot more natural!

SELECT CONVERT(Date, GETDATE())

这篇关于将“date”从SQL Server中的DateTime字段中取出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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