Mysql time type Summary

Source: Internet
Author: User
In MySQL databases, there are four types of Date and time: Date, DateTime, TimeStamp, Time1, and DATETIME: used when you need to include Date and time information at the same time. MySQL retrieves and displays DATETIME in YYYY-MM-DDHH: MM: SS format, with a supported range of 1000-01-0100:00:00 to 9999-12-3123: 59: 59

In MySQL databases, there are four types of Date and Time: Date, DateTime, TimeStamp, and Time 1. DATETIME type: used when you need to include Date and Time information at the same Time. MySQL retrieves and displays datetime in the 'yyyy-MM-DD HH: MM: ss' format. The supported range is '2017-01-01 00:00:00 'to '2017-12-31 23:59:59'

In MySQL databases, there are four types of Date and Time: Date, DateTime, TimeStamp, and Time


1. DATETIME type: It is used when you need to include both date and time information. MySQL retrieves and displays DATETIME values in 'yyyy-MM-DD HH: MM: ss' format, the supported range is '2017-01-01 00:00:00 'to '2017-12-31 23:59:59 '.

2. The DATE type is used when you only need the DATE value, and there is no time part. MySQL retrieves and displays the DATE value in 'yyyy-MM-DD 'format. The supported range is '2017-01-01' to '2017-12-31 '.


3. TIMESTAMP type: Provides date and time information, also displayed in 'yyyy-MM-DD HH: MM: ss' format. The difference between datetime type and datetime type is that the storage time is small, and the number of years is between 1970 and 2037. You can use it to automatically mark INSERT or UPDATE operations with the current date and time (automatically refresh when updated by default ).


4. the TIME data type indicates the TIME in a day. MySQL retrieves and displays the TIME value in the format of "HH: MM: SS. The supported range is '00: 00: 00' to '23: 59: 59 '.

Instance:

Test Table Structure:


Insert data:


View:


Update:


The timestamp field is automatically inserted.

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.