我有一个包含 CreationDate 字段的 SQL 表.
I have a SQL table that has a CreationDate field.
我在计算列规范公式中有 getdate().
I have getdate() in the computed column specification formula.
我想知道如何只获取日期部分,即2012-08-24"而不是2012-08-24 10:45:17.740".
I would like to know how to get just the date portion, that is, '2012-08-24' instead of '2012-08-24 10:45:17.740'.
如果您使用的是 SQL Server 2008 或更高版本
If you are using SQL Server 2008 or later
select convert(date, getdate())
否则
select convert(varchar(10), getdate(),120)
这篇关于如何只获取 getdate() 的日期部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
截断时的 SQL 触发器SQL trigger on Truncate(截断时的 SQL 触发器)
具有多个可选搜索参数的 sql 搜索查询sql search query with multiple optional search parameters(具有多个可选搜索参数的 sql 搜索查询)
SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUPSQL Efficiency: WHERE IN Subquery vs. JOIN then GROUP(SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP)
使用 t-SQL 检索 XML 元素名称Retrieving XML element name using t-SQL(使用 t-SQL 检索 XML 元素名称)
在 SQL 输出中插入双引号Insert double quotes into SQL output(在 SQL 输出中插入双引号)
从 SQL SERVER 中的 CTE 中删除行Delete rows from CTE in SQL SERVER(从 SQL SERVER 中的 CTE 中删除行)