MS SQL Server中 CONVERT日期格式化
来源:互联网 发布:网络暴力案例分析ppt 编辑:程序博客网 时间:2024/05/18 01:45
CONVERT 将某种数据类型的表达式显式转换为另一种数据类型。由于某些需求经常用到不同日期格式的转换。
SQL Server 支持使用科威特算法的阿拉伯样式中的数据格式。
在表中,左侧的两列表示将 datetime 或 smalldatetime 转换为字符数据的 style 值。给 style 值加 100,可获得包括世纪数位的四位年份 (yyyy)。
标准:输入/输出**
0 100 默认值 mon dd yyyy hh:miAM(或 PM)
1 101 美国 mm/dd/yyyy
2 102 ANSI yy.mm.dd
3 103 英国/法国 dd/mm/yy
4 104 德国 dd.mm.yy
5 105 意大利 dd-mm-yy
6 106 - dd mon yy
7 107 - mon dd, yy
8 108 - hh:mm:ss
9 109 默认值 + 毫秒 mon dd yyyy hh:mi:ss:mmmAM(或 PM)
10 110 美国 mm-dd-yy
11 111 日本 yy/mm/dd
12 112 ISO yymmdd
13 113 欧洲默认值 + 毫秒 dd mon yyyy hh:mm:ss:mmm(24h)
14 114 hh:mi:ss:mmm(24h)
20 120 ODBC 规范 yyyy-mm-dd hh:mm:ss[.fff]
21 121 ODBC 规范(带毫秒) yyyy-mm-dd hh:mm:ss[.fff]
126 ISO8601 yyyy-mm-dd Thh:mm:ss:mmm(不含空格)
130 科威特 dd mon yyyy hh:mi:ss:mmmAM
131 科威特 dd/mm/yy hh:mi:ss:mmmAM
CONVERT (data_type[(length)], expression [, style])
EG:
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
- MS SQL Server中 CONVERT日期格式化
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的 CONVERT 日期时间 格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- MS SQL Server中的CONVERT日期格式化大全
- sql server----sql convert函数,日期格式化
- SQL SERVER convert函数日期格式化应用
- sql server中的convert日期格式化大全
- SQL SERVER convert函数日期格式化应用
- SQL SERVER convert函数日期格式化应用
- SQL Server中的CONVERT日期格式化大全
- My97---onpicked
- 从DataTable获取所有数据
- DSL Forum首席运营官Robin Mersh在中国的演讲
- 灵活数组成员(fleible array member)
- 基于COM接口的Shell扩展技术应用
- MS SQL Server中 CONVERT日期格式化
- CocoaX、Code、Objective-C语法快速参考
- cache protocol
- SOA与BPM的融合
- (转)在敏捷测试中如何设计用例
- sql cluster
- 在存储过程中排序分页
- 李开复揭密微软成功之道 寄语中国软件业
- sql cluster