Home > Database > Mysql Tutorial > sql 字符串转换日期

sql 字符串转换日期

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 17:47:56
Original
3592 people have browsed it

文章主要讲mssql server 的sql 字符串转换日期函数与实例用法 了,下面我们收集了很多种关于字符串转换成日期的sql语句。

文章主要讲mssql server 的sql 字符串转换日期函数与实例用法 了,下面我们收集了很多种关于字符串转换成日期的sql语句。

update testonline set testdate=substring(testdate,1,10)
update testonline set testdate=replace(testdate,'/','-')
update testonline set testdate=replace(testdate,'-0','-')


如何将字符型'2007-01'转换成日期型'2007-01'

cast('2007-01' + '-01' as datetime)


'2007-01'不是日期型转不了。

可以转成'2007-01-01',

cast('2007-01'+'-01' as datetime)


实例三

select*from表where字段

select*from表wherecast(replace(replace(replace('2006年8月15日','年','-'),'月','-'),'日','')asdatetime)

 

Related labels:
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
Latest Issues
sql file
From 1970-01-01 08:00:00
0
0
0
php - Overhead of prepare vs sql?
From 1970-01-01 08:00:00
0
0
0
Print sql statement
From 1970-01-01 08:00:00
0
0
0
Pass array to SQL insert query using PHP
From 1970-01-01 08:00:00
0
0
0
sql optimization or
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template