Examveda

Which is the correct format to store date in the SQL?

A. DEC-01-1991

B. 01-1991-11

C. 01-DEC-12

D. 1991-11-01

Answer: Option D

Solution (By Examveda Team)

This question asks about the correct way to store a date in a MySQL database.
MySQL has a specific format for storing dates, and it's important to use the right format so your database can understand and work with the dates correctly.
Let's look at the options:
Option A: DEC-01-1991
This format uses abbreviations for the month ("DEC" for December), which is not the standard way MySQL expects dates.
Option B: 01-1991-11
This format is also incorrect because it puts the day before the year, which isn't the standard order.
Option C: 01-DEC-12
This option is similar to Option A, using an abbreviation for the month, and is therefore also incorrect.
Option D: 1991-11-01
This is the correct format for storing dates in MySQL. It follows the standard YYYY-MM-DD format, where:
- YYYY represents the year (e.g., 1991)
- MM represents the month (e.g., 11 for November)
- DD represents the day (e.g., 01 for the 1st)
Therefore, the answer is Option D: 1991-11-01.
Always remember to use the YYYY-MM-DD format when storing dates in MySQL to ensure consistency and avoid errors.

This Question Belongs to MySQL >> MySQL Miscellaneous

Join The Discussion

Related Questions on MySQL Miscellaneous