Home  >  Article  >  Database  >  mysql str_to_date字符串转换为日期_MySQL

mysql str_to_date字符串转换为日期_MySQL

WBOY
WBOYOriginal
2016-06-01 13:36:471272browse

bitsCN.com

mysql str_to_date字符串转换为日期

 

mysql内置函数,在mysql里面利用str_to_date()把字符串转换为日期。

 

实例:    

 

分隔符一致,年月日要一致

 

select str_to_date('02/25/1998 12:00:34 AM','%m/%d/%y %h:%i:%s %s') as column_name from table_name;

 

str_to_date('11/09/2011', '%m/%d/%Y'); -- 2011-11-09

 

str_to_date('11/09/11' , '%m/%d/%y'); -- 2011-11-09

 

str_to_date('11.09.2011', '%m.%d.%Y'); -- 2011-11-09

 

str_to_date('11:09:30', '%h:%i:%s'); -- 11:09:30

 

str_to_date('11.09.2011 11:09:30', '%m.%d.%Y %h:%i:%s'); -- 2011-11-09 11:09:30

 

bitsCN.com
Statement:
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