How to select only date from a DATETIME field in MySQL?

I have a table in the MySQL database that is set up with DATETIME. I need to SELECT in this table only by DATE and excluding the time.

How do I SELECT in this table by only date and bypassing the time, even if that specific column is set to DATETIME?


Example

Now it is: 2012-01-23 09:24:41

I need to do a SELECT only for this: 2012-01-23


SELECT DATE(ColumnName) FROM tablename;

More on MySQL DATE() function.


you can use date_format

select DATE_FORMAT(date,'%y-%m-%d') from tablename

for time zone

sql2 = "SELECT DATE_FORMAT(CONVERT_TZ(CURDATE(),'US/Central','Asia/Karachi'),'%Y-%m-%d');"

You can use select DATE(time) from appointment_details for date only

or

You can use select TIME(time) from appointment_details for time only


Try to use
for today:

SELECT * FROM `tbl_name` where DATE(column_name) = CURDATE()


for selected date:

SELECT * FROM `tbl_name` where DATE(column_name) = DATE('2016-01-14')