Mysql operations (5)

Source: Internet
Author: User


Mysql those things (5) operation time I. Time Command: SELECT CURDATE (); function: return today's date value in 'yyyy-MM-DD 'format. Command: select curtime (); function: return time in 'hh: MM: ss' format. Command: select now (); function: return time in 'yyyy-MM-DD HH: MM: ss' format. II. The automatic record time of the www.2cto.com TIMESTAMP column type can automatically mark the insert update operation time. Example: create table student (id INT, english TINYINT, math TINYINT, chinese TINYINT, time TIMESTAMP); INSERT data: insert into student (id, english, math, chinese) VALUES (,); query data: SELECT * FROM student; Result: student id | english | math | chinese | time | minute 1 | 12 | 23 | 45 | 10:34:09 ------------------------------------------------------------------------- The time column automatically adds the data INSERT time. UPDATE also affects the time value of the time column of the data. The storage requirement of TIMESTAMP is 4 bytes; that of DATETIME is 8 bytes. Www.2cto.com 3. Comparison time select TO_DAYS (date); returns a date, and returns the number of days from 0 years (until date ). Example: SELECT TO_DAYS (NOW ()-TO_DAYS ('1970-10-19 '): return 1 day. SELECT TO_DAYS (NOW (); returns the 735161 day. That is, the number of days from now until 0 years.

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.