MySQL Time function date_format

Source: Internet
Author: User

http://toptree.iteye.com/blog/812642 today, in the development of the mail system to find a lot of mail is not sent successfully, want to manually change the data. Find the MySQL date function

The obtained pubtime is a string type, which is converted in the SQL statement using the MySQL time function date_format (' Times ', ' format '):

String sqlstr= "SELECT * from Do_document where

Pub_time<date_format (' +pubtime+ ', '%y-%m-%d%h:%i:%s ') Order BY pub_time desc limit 0,1 ";

The SQL statement is then executed to find the record that satisfies the condition.

Usage:

  Select COUNT (*) from MESSAGE where Date_format (sendtime, '%y-%m-%d ') = ' 2010-11-16 '

SELECT COUNT (*) from test_table where ActivityID in ( -1,4) and Weibotime < Str_to_date (' 2011-09-01 00:00:00 ', '% y-%m-%d%h:%i:%s ')

MySQL Time function date_format

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.