How to change the date type to the form of the desired character

Published in Server
January 21, 2023
1 min read

When using MYSQL, there are many times when the column of the date type is changed to the form of a character. The MYSQL function used in that case is a function called date_format. As shown below, you can output a variety of date data.

SELECT date_format(now(),'%m/%d/%y') AS DATE FROM DUAL
-- Result) 09/14/23
  • now() is a function that returns the current time as a date type.

Time is also available.

SELECT date_format(now(),'%H:%i:%S') AS DATE FROM DUAL
-- Result) 18:20:32

Date and time can be printed at the same time.

SELECT date_format(now(),'%m/%d/%y %H:%i:%S') AS DATE FROM DUAL
-- Result) 09/14/22 18:21:46




Previous Article
When creating text files in Java, the io method and the nio method are used



Related Posts

Calculating Date, Time in SQL-mysql
May 16, 2023
1 min