hello all...
i have a field inside table inspection,it is inspection_datetime.
the type of field is datetime, so that make the data like yy/mm/dd hh:mm:ss
.
my question is how do i do if i want to show date only from the data?
views:
17answers:
3
+2
A:
Or you can use Date_Format if you want MySQL to do it:
SELECT DATE_FORMAT(inspection_datetime, "%Y/%m/%d")
Raze2dust
2010-07-29 06:58:48
+1
A:
If you have access to PHP 5.3.0 or greater, the DateTime class DateTime::format function makes formatting dates and times easy:
$dt = new DateTime($db_datetime);
echo $dt->format('Ymd');
// 20101231
echo $dt->format('Y-m-d');
// 2010-12-31
echo $dt->format('Y-M-d');
//2010-Dec-31
Mike
2010-07-29 06:59:58
+1
A:
There are a few solutions, including formatting the data in SQL or in PHP as given in other answers.
Another option is to return just the date portion from the datetime column:
SELECT DATE(inspection_datetime) FROM inspection
Bill Karwin
2010-07-29 07:01:18