Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select date and time without the seconds in mysql?

How do I select date and time without the seconds in mysql from a column with date value in a table ? "YYYY-MM-DD HH:MM:SS" should be "YYYY-MM-DD HH:MM"

like image 507
Sjemmie Avatar asked Jul 16 '11 16:07

Sjemmie


People also ask

How do you display time and date in MySQL?

MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59' . The TIMESTAMP data type is used for values that contain both date and time parts.

How do I select a specific date in MySQL?

You can use DATE() from MySQL to select records with a particular date. The syntax is as follows. SELECT *from yourTableName WHERE DATE(yourDateColumnName)='anyDate'; To understand the above syntax, let us first create a table.

Should I use datetime or TIMESTAMP MySQL?

To summarize, if you want to serve your date and time data the same way regardless of timezones, you can use the DATETIME type (which will also allow you to use all the date & type functions built in MySQL). Otherwise, you can use TIMESTAMP and serve the data on a per-timezone basis.

What is now () in MySQL?

MySQL NOW() Function The NOW() function returns the current date and time. Note: The date and time is returned as "YYYY-MM-DD HH-MM-SS" (string) or as YYYYMMDDHHMMSS. uuuuuu (numeric).


1 Answers

SELECT DATE_FORMAT(`date`, '%Y-%m-%d %H:%i') AS `formatted_date` FROM `table`; 
like image 167
Ruslan Polutsygan Avatar answered Oct 11 '22 09:10

Ruslan Polutsygan