COMPUTER SCIENCE AND ENGINEERING
SQL
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
DD-MM-YYYY
|
|
YY-MM-DD
|
|
YYYY-MM-DD
|
|
None of the above
|
Detailed explanation-1: -MySQL uses yyyy-mm-dd format for storing a date value. This format is fixed and it is not possible to change it. For example, you may prefer to use mm-dd-yyyy format but you can’t. Instead, you follow the standard date format and use the DATE FORMAT function to format the date the way you want.
Detailed explanation-2: -Use STR TO DATE() method from MySQL to convert. The syntax is as follows wherein we are using format specifiers. The format specifiers begin with %. SELECT STR TO DATE(yourDateColumnName, ’%d.
Detailed explanation-3: -MySQL retrieves and displays DATE values in ‘ YYYY-MM-DD ‘ format. The supported range is ‘1000-01-01’ to ‘9999-12-31’ . The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ‘ YYYY-MM-DD hh:mm:ss ‘ format.
Detailed explanation-4: -Simply use the CURDATE() function to get the current date. The date can be displayed in two different formats: ‘ YYYY-MM-DD ‘ if it is used in a string context or YYYYMMDD if it is used in a numeric context. There are two other functions that can be used instead of CURDATE() : CURRENT DATE and CURRENT DATE() .