Some issues with MySQL time fields

Source: Internet
Author: User

There are several types of data that represent dates and times in MySQL. Where year represents the years, date represents the dates, time represents the times, and datetime and timestamp represent dates and practices. Their comparison is as follows:

Year, byte number 1, Value range "1901--2155"

DATE, byte number 4, Value range "1000-01-01--9999-12-31"

Time, byte number 3, value range " -838:59:59--838:59:59"

DATETIME, byte number 8, value range "1000-01-01 00:00:00--9999-12-31 23:59:59"

TIMESTAMP, byte number 4, Value range "19700101080001--20380119111407"

When the insertion value exceeds a valid range of values, the system will error and insert a value of 0 into the database.

Date in date format: YYYY-MM-DD
Date and time in datetime format: YYYY-MM-DD hh:mm:ss
Timestamp format date and time: YYYYMMDDHHMMSS

Some issues with MySQL time fields

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.