SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm
例如:
select getdate()
2004-09-12 11:06:08.177
整理了一下SQL Server里面可能经常会用到的日期格式转换方法:
举例如下:
select CONVERT(varchar, getdate(), 120 )
2004-09-12 11:06:08
select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),'-',''),' ',''),':','')
20040912110608
select CONVERT(varchar(12) , getdate(), 111 )
2004/09/12
select CONVERT(varchar(12) , getdate(), 112 )
20040912
select CONVERT(varchar(12) , getdate(), 102 )
2004.09.12
select CONVERT(varchar(12) , getdate(), 101 )
09/12/2004
select CONVERT(varchar(12) , getdate(), 103 )
12/09/2004
select CONVERT(varchar(12) , getdate(), 104 )
12.09.2004
select CONVERT(varchar(12) , getdate(), 105 )
12-09-2004
select CONVERT(varchar(12) , getdate(), 106 )
12 09 2004
select CONVERT(varchar(12) , getdate(), 107 )
09 12, 2004
select CONVERT(varchar(12) , getdate(), 108 )
11:06:08
select CONVERT(varchar(12) , getdate(), 109 )
09 12 2004 1
select CONVERT(varchar(12) , getdate(), 110 )
09-12-2004
select CONVERT(varchar(12) , getdate(), 113 )
12 09 2004 1
select CONVERT(varchar(12) , getdate(), 114 )
11:06:08.177
帮助文档中的信息
Without century (yy)
|
With century (yyyy)
|
Standard
|
Input/Output**
|
-
|
0 or 100 (*)
|
Default
|
mon dd yyyy hh:miAM (or PM)
|
1
|
101
|
USA
|
mm/dd/yy
|
2
|
102
|
ANSI
|
yy.mm.dd
|
3
|
103
|
British/French
|
dd/mm/yy
|
4
|
104
|
German
|
dd.mm.yy
|
5
|
105
|
Italian
|
dd-mm-yy
|
6
|
106
|
-
|
dd mon yy
|
7
|
107
|
-
|
Mon dd, yy
|
8
|
108
|
-
|
hh:mm:ss
|
-
|
9 or 109 (*)
|
Default + milliseconds
|
mon dd yyyy hh:mi:ss:mmmAM (or PM)
|
10
|
110
|
USA
|
mm-dd-yy
|
11
|
111
|
JAPAN
|
yy/mm/dd
|
12
|
112
|
ISO
|
yymmdd
|
-
|
13 or 113 (*)
|
Europe default + milliseconds
|
dd mon yyyy hh:mm:ss:mmm(24h)
|
14
|
114
|
-
|
hh:mi:ss:mmm(24h)
|
-
|
20 or 120 (*)
|
ODBC canonical
|
yyyy-mm-dd hh:mi:ss(24h)
|
-
|
21 or 121 (*)
|
ODBC canonical (with milliseconds)
|
yyyy-mm-dd hh:mi:ss.mmm(24h)
|
-
|
126(***)
|
ISO8601
|
yyyy-mm-dd Thh:mm:ss:mmm(no spaces)
|
-
|
130*
|
Kuwaiti
|
dd mon yyyy hh:mi:ss:mmmAM
|
-
|
131*
|
Kuwaiti
|
dd/mm/yy hh:mi:ss:mmmAM
|
分享到:
相关推荐
sql server日期格式转换方法大全
Sql Server日期格式转换是我们在使用Sql Server数据库时经常用到的操作,下面就将为您举一个Sql Server日期格式转换的例子,供您参考,希望对您学习Sql Server日期格式转换有所帮助。
本篇文章是对SQL SERVER 日期格式转换进行了详细的分析介绍,需要的朋友参考下
亲测正确、有效的格式转换方法,试用于常见的应用场景。适合熟悉oracle,但在用SQLServer的小伙伴。
本部分文档主要是对sqLserver中的日期格式转换进行了详细的记载,包含各种日期格式的转换。
SqlServer日期转换 能够将sql server 的日期类型 以不用表示格式进行输出显示
Sql日期时间格式转换方法,将日期转换为各种格式
SQLServer 数据库语句:日期/时间格式转换语句示例。
将sql sqlser 日期类型转化成各种格式的字符串。
Sql Server 中利用Convert 函数转换日期格式,请使用者通读。
SqlServer时间日期处理函数及字符串转换 SqlServer时间日期处理函数及字符串转换 文章分类:数据库 最近做的报表,用SqlServer2005,边做边学吧,虽然速度有些慢~
整理了一下SQL Server里面可能经常会用到的日期格式转换方法,整合一个函数来处理。 调用: select dbo.func_Print_DateFormat('yyyy-MM-dd',getdate()) 函数: GO /****** Object: UserDefinedFunction [dbo]....
本文主要通过一下几个方面介绍:使用SQLDMV查找慢速查询、通过APM解决方案查询报告、SQLServer扩展事件、SQLAzure查询性能洞察等相关内容。本文来自博客园,由火龙果软件Anna编辑、推荐。SQLServer的一个重要功能是...
这个系统不小,如果要将里面的SQL全部转换为Oracle,需要大量的时间及人力和物力,为了在短期 内完成任务,小弟想到了“自动翻译”的方法,其难度是可想而知的,不过幸好我们的系统设计还算 合理,所在的SQL都是...
这是我收集的关于数据库中时间格式的一些转换及设置,其中还有时间日期的相关操作,适合有需要的朋友参考
主要介绍了C#更新SQLServer中TimeStamp字段(时间戳)的方法,涉及C#操作数据库字段的相关技巧,需要的朋友可以参考下
sqlserver 计算当月所有自然周的区间。
sql server 时间格式的转换,用sql语句对时间格式进行转换,方便实用。
示例中列出了三种实现在SQL中将日期转换为中文大写的方法,两种通过函数实现,一种通过存储过程实现。