본문 바로가기

카테고리 없음

MySQL 날짜 형식의 이해와 활용법을 알아보자.

MySQL Date Format

MySQL uses a specific date format to store and manipulate dates and times in databases. The standard date format used in MySQL is 'YYYY-MM-DD' for dates and 'HH:MM:SS' for times.

Here are some important points to remember about the MySQL date format:

  1. Date Data Type: MySQL has date-specific data types such as DATE, DATETIME, and TIMESTAMP to store dates and times in a database.

  2. Default Format: The default date format used in MySQL is 'YYYY-MM-DD'. For example, '2022-03-15' represents the 15th of March, 2022.

  3. Time Data Type: The time data type in MySQL can store time values in the format 'HH:MM:SS'. For example, '14:30:00' represents 2:30 PM.

  4. Combined Date and Time: The DATETIME data type in MySQL can store both date and time values in the format 'YYYY-MM-DD HH:MM:SS'. For example, '2022-03-15 14:30:00' represents the 15th of March, 2022 at 2:30 PM.

  5. Formatting Functions: MySQL provides formatting functions such as DATE_FORMAT() to convert date and time values into different formats according to your requirements.

By understanding the MySQL date format and using the appropriate data types, you can efficiently store and retrieve date and time information in your database.