Page 1 of 1

DATETIME Function

Posted: Tue Apr 10, 2007 8:26 am
by pkvasan
Hi

MySQL contains a Table with field name as Start time which is of Data Type DATETIME the Data stored in that is like 2007-01-30 14:06:00

now i want to display only Date from Date Time that is i want to display 2007-01-30 only how do i do that please help me

Posted: Tue Apr 10, 2007 8:28 am
by feyd
Do it in the query via the DATE_FORMAT() function provided by MySQL.

Posted: Tue Apr 10, 2007 8:32 am
by Maugrim_The_Reaper
DATE_FORMAT() if possible within the MySQL query, otherwise you can extract the format using PHP after the query results are accessible.

Code: Select all

$datetime = "2007-01-30 14:06:00";
$myDate = substr($datetime, 0, 10); // 2007-01-30 (sub-string of length 10 characters from position 0)
echo $myDate;

Posted: Tue Apr 10, 2007 11:20 am
by RobertGonzalez
MySQL DATE() function, if your mysql version supports it.