CONVERT function [Data type conversion]
来源:互联网 发布:手机淘宝能开网店么 编辑:程序博客网 时间:2024/06/06 09:26
http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc38151.1510/html/iqrefbb/Convert.htm
Returns an expression converted to a supplied data type.
CONVERT ( data-type, expression [ , format-style ] )
For converting strings to date or time data types and vice versa,format-style is a style code number that describes the date format string to be used.Table 4-17 lists the meanings of the values of theformat-style argument.
Without century (yy)
With century (yyyy)
Output
-
0 or 100
mmm dd yyyy hh:nnAM (or PM)
1
101
mm/dd/yy[yy]
2
102
[yy]yy.mm.dd
3
103
dd/mm/yy[yy]
4
104
dd.mm.yy[yy]
5
105
dd-mm-yy[yy]
6
106
dd mmm yy[yy]
7
107
mmm dd, yy[yy]
8
108
hh:nn:ss
-
9 or 109
mmm dd yyyy hh:nn:ss:sssAM (or PM)
10
110
mm-dd-yy[yy]
11
111
[yy]yy/mm/dd
12
112
[yy]yymmdd
13
113
dd mmm yyyy hh:nn:ss:sss (24 hour clock, Europe default + milliseconds, 4-digit year)
14
114
hh:nn:ss (24 hour clock)
20
120
yyyy-mm-dd hh:nn:ss (24-hour clock, ODBC canonical, 4-digit year)
21
121
yyyy-mm-dd hh:nn:ss.sss (24 hour clock, ODBC canonical with milliseconds, 4-digit year)
-
365
yyyyjjj (as a string or integer, where jjj is the Julian day number from 1 to 366 within the year)
If no format-style argument is provided, style code 0 is used.
The following statements illustrate the use of format styles:
SELECT CONVERT( CHAR( 20 ), order_date, 104 )FROM sales_order
order_date
16.03.1993
20.03.1993
23.03.1993
25.03.1993
...
SELECT CONVERT( CHAR( 20 ), order_date, 7 )FROM sales_order
order_date
mar 16, 93
mar 20, 93
mar 23, 93
mar 25, 93
...
The following statements illustrate the use of the format style 365, which converts data of typeDATE and DATETIME to and from either string or integer type data:
CREATE TABLE tab (date_col DATE, int_col INT, char7_col CHAR(7));INSERT INTO tab (date_col, int_col, char7_col) VALUES (‘Dec 17, 2004’, 2004352, ‘2004352’);
SELECT CONVERT(VARCHAR(8), tab.date_col, 365) FROM tab;
returns ‘2004352’
SELECT CONVERT(INT, tab.date_col, 365) from tab;
returns 2004352
SELECT CONVERT(DATE, tab.int_col, 365) FROM TAB;
returns 2004-12-17
SELECT CONVERT(DATE, tab.char7_col, 365) FROM tab;
returns 2004-12-17
The following statement illustrates conversion to an integer, and returns the value 5.
SELECT CONVERT( integer, 5.2 ) FROM iq_dummy
The result data type of a CONVERT function is a LONG VARCHAR. If you useCONVERT in a SELECT INTO statement, you must have a Large Objects Management option license or useCAST and set CONVERT to the correct data type and size.
See
“REPLACE function [String]” for more information.
“CAST function [Data type conversion]”
- CONVERT function [Data type conversion]
- Data type conversion
- matlab Data Type Conversion
- Data Type convert
- Data Type convert
- Aggregate Function Data Type
- Data type conversion sheet : C++ to .NET
- function-style conversion to builtin type takes only one argument
- AJAX - $.post(url,data,function,type)
- AJAX - $.post(url,data,function,type)-2
- AJAX - $.post(url,data,function,type)-3
- (转贴)Data type conversion sheet : C++ to .NET
- sql server data type conversion - 案例 ( 一 )
- Failed to convert value of type...no matching editors or conversion strategy found
- [TI DLP Buglist]data type error in illum_EnableIllumination function
- Type-Conversion in Javascript
- C++ frequent type conversion
- Convert internal table data into HTML format without using Function Modules
- c代码片段——在自己代码中即时接收errno
- wpf 中的treeviewitem:基于数据初始化控件 数据动态加载 右键选中
- 关于Android的DEX文件
- struts1.3总结
- 堆排序_最大优先队列
- CONVERT function [Data type conversion]
- MongoDB使用教程
- css+html简单布局demo
- LabVIEW上位机与串口通信
- CentOS配置smaba与Windows共享文件
- Access 操作或事件已被禁用模式阻止
- 正则表达式的使用
- 判断是否为 数字 小数
- Impala源码分析---1