vcodeinfote Posted July 25, 2008 Share Posted July 25, 2008 Hello, Can anyone help me!!! 2008-07-06 16:46:15 2008-07-06 16:47:44 2008-07-06 10:18:25 2008-07-24 14:38:25 If these are the records in a table i need to get the output like this: 2008-07-06 2008-07-24 Please help Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/ Share on other sites More sharing options...
mmarif4u Posted July 25, 2008 Share Posted July 25, 2008 you can use date function. like this: $date=date('m-d-Y',strtotime($row['date'])); echo $date; $row['date'] is fetching from table. Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-599268 Share on other sites More sharing options...
abhikerl Posted July 25, 2008 Share Posted July 25, 2008 visit http://www.php.net/date. You will get good example. This helped me out too when I was dealing with date on a project. Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-599289 Share on other sites More sharing options...
samshel Posted July 25, 2008 Share Posted July 25, 2008 Check this out. http://dev.mysql.com/doc/refman/4.1/en/date-and-time-functions.html#function_date-format Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-599302 Share on other sites More sharing options...
waynew Posted July 25, 2008 Share Posted July 25, 2008 $result = mysql_query("SELECT DAY(example_date), MONTH(example_date), YEAR(example_date) FROM example_table WHERE example_id = $id"); while($row = mysql_fetch_assoc($result)){ $day = $row['DAY(example_date)']; $month = $row['MONTH(example_date)']; $year = $row['YEAR(eample_date)']; } Not the best example but it does contribute. Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-599334 Share on other sites More sharing options...
PFMaBiSmAd Posted July 26, 2008 Share Posted July 26, 2008 To get a list of distinct dates from a DATETIME column - SELECT DISTINCT DATE(your_datetime_column) FROM your_table ORDER BY your_datetime_column Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-600049 Share on other sites More sharing options...
rawb Posted July 26, 2008 Share Posted July 26, 2008 Hello, Can anyone help me!!! 2008-07-06 16:46:15 2008-07-06 16:47:44 2008-07-06 10:18:25 2008-07-24 14:38:25 If these are the records in a table i need to get the output like this: 2008-07-06 2008-07-24 Please help If you're using PHP to display the result check out substr - http://www.php.net/substr echo substr($date, 0, 10); will turn '2008-07-06 16:46:15' to '2008-07-06' Link to comment https://forums.phpfreaks.com/topic/116545-date-extracting-function-in-sql/#findComment-600053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.