Home mysql Date and Time field type in MySQL

Date and Time field type in MySQL

Author

Date

Category

Who knows, please tell me. What is the difference and what field types are given: date, time, datetime, timestamp and year?


Answer 1, Authority 100%

In detail about all types, this MySQL can be read here: Data Types MySQL . Regarding the types of you:

date
Date. The interval from ‘1000-01-01’ to ‘9999-12-31’ is maintained. MySQL displays the Date value in the format ‘yyyy-mm-dd’, but you can set the values ​​to the Date column using both rows and numbers.

Time
Time. Interval from ‘-838: 59: 59’ up to ‘838: 59: 59’. MySQL displays the Time value in the ‘HH: mm: SS’ format, but you can set values ​​in the Time column using both rows and numbers.

DateTime
Combination of dates and time. The interval is supported from ‘1000-01-01 00:00:00’ up to ‘9999-12-31 23:59:59’. MySQL Displays DateTime Values ​​in the ‘Yyyy-MM-DD HH: MM: SS’ format, but you can set the values ​​in the DateTime column using both the rows and the numbers

TimeStamp
Temporary label. Interval from ‘1970-01-01 00:00:00’ to some time in 2037. MySQL displays TimeStamp values ​​in yyyymmddhhmss, yymmddhhmss, yyyymmdd or yymmdd formats depending on the values ​​M: 14 (or missing), 12, 8, or 6; But you can also set values ​​in the TimeStamp column, using both rows and numbers. The TimeStamp column is useful for recording the date and time when performing INSERT or UPDATE operations, since the date and time values ​​are automatically entered, if these values ​​are not entered by the program. You can also set the current date and time value by setting the value null

Year
The year in two-digit or four-digit formats (by default four-digit format). The following values ​​are permissible: from 1901 to 2155, 0000 for the four-digit format of the year and 1970-2069 when using a two-digit format (70-69). MySQL displays the YEAR values ​​in yyyy format, but you can set the values ​​in the Year column using both the rows and numbers (the YEAR data type is not available in the versions of the preceding MYSQL 3.22)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions