Home > Database > Mysql Tutorial > mysql语句中把string类型字段转datetime类型_MySQL

mysql语句中把string类型字段转datetime类型_MySQL

WBOY
Release: 2016-06-01 13:48:08
Original
3648 people have browsed it

bitsCN.com
mysql语句中把string类型字段转datetime类型 在mysql里面利用str_to_date()把字符串转换为日期 此处以表h_hotelcontext的Start_time和End_time字段为例,查询当前时间在此范围之内的数据。     select * from h_hotelcontext where now() between STR_TO_DATE(Start_time,'%Y-%m-%d %H:%i:%s') and STR_TO_DATE(End_time,'%Y-%m-%d %H:%i:%s');  注:'%Y-%m-%d %H:%i:%s'格式为:2012-10-11 16:42:30 bitsCN.com

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