As it mentioned in title, how can I achieve this?
Use Date_format
, i.e.
select date_format(fieldname,'%Y%m%d') from ...;
You can find more information in the manual at http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
Simple way to check from the command line:
select date_format(now(),'%Y%m%d');
This just formats today as CCYYMMDD.
You have 2 options ...
Use MySQL on select -> http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
example :
select date_format(<yourDateField>,'%Y%m%d') from ...;
Use PHP on the result -> http://www.php.net/manual/en/datetime.format.php
example :
$date = new DateTime($yourDateField);
echo $date->format('Ymd');