Convert string type fields to datetime type _ mysql in MySQL statements

Source: Internet
Author: User
Convert string type fields to datetime type bitsCN.com in mysql statements
In a mysql statement, convert a string-type field to a datetime-type field. in mysql, use str_to_date () to convert a string to a date. here, the Start_time and End_time fields in the h_1_context table are used as an example, query the data within the specified time range. Select * from h_shortcontext 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'); Note:' % Y-% m-% d % H: % I: % s' format: 2012-10-11 16: 42: 30bitsCN.com
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.