MySQL: date type, mysql date type

Source: Internet
Author: User

MySQL: date type, mysql date type

1. datetime (year, month, day, hour, minute, second)

Format: 'yyy-MM-DD HH: MM: ss '.

Occupied: 8 bytes

Range: 1000-01-01 00:00:00 to 9999-12-31 23:59:59.

Tip: it can receive dates of any separator, mainly to determine whether the date is correct and whether it is within the correct range.

However, non-General delimiters are less readable and are not recommended:

Tip: when the year is expressed in two digits, it must be 70 ~ 99 represents 1979 ~ 1999, while 00 ~ 69 represents 2000 ~ 2069.

If only the year, month, and day are provided, and the time and second are not written, the default time and second part is 00:00:00.

Value 0: indicates that there is no rule currently.

2013-04-0 indicates the entire month of January 1, April.

2. date (year, month, and day)

3. timestamp (timestamp)

It is an integer, but it is similar to the datetime type.

Usage: 4 bytes

Range: 00:00:00 to 03:14:07 (affected by the integer size)

When the insertion time exceeds the preceding range, an error is returned and cannot be inserted correctly.

Tip: When retrieving a column, + 0 can retrieve the timestamp:

 

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.