Using substring directly onto a date/datetime column , treated as a string, isn't good idea. DATETIME can be represented in different ways, depends on internal MySQL date_format configuration: So, it's better using functions like YEAR(),MONTH(),DAY(),HOUR(),MINUTE()... to extract desired portions and then concatenate them.Example: SELECT CONCAT(YEAR(NOW()),'-',MONTH(NOW()),'-',DAY(NOW())) AS DESIRED; Code (markup): Regards
What is your requirement? You can also use DATE_FORMAT() function to get the desired output. Some examples from the MySQL Manual