Home > Database > Mysql Tutorial > sql CONVERT() 字符串转整型 日期 字符型

sql CONVERT() 字符串转整型 日期 字符型

WBOY
Release: 2016-06-07 17:47:56
Original
1954 people have browsed it

sql convert() 字符串转整型 日期 字符型

转换成日期写法

convert(data_type(length),data_to_be_converted,style)

实例

select convert(varchar(30),getdate(),101) now


转换成整型

convert( int, column )

如我要把手机号转换成整型,

select convert(int(8),mo) moint

会报错,为什么,下面我们再看一下实例。

select convert(bigint,mo) moint


这样就正确了,原因是数字类型不正确,手机号是11位,而int型只能是8位,自然

会出错了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template