我有一些數據在數據庫中,我需要排序時間上午/下午。無法排序時間(varchar類型)在上午/下午查詢
我的代碼
$current_dat=date("m/d/Y");
$ current_dat_short = SUBSTR($ current_dat,0,2);
$ rest = substr($ current_dat,-7,2);
$sql_timesheet=mysql_query('SELECT * FROM timesheet WHERE reg_id='.$regiD.' AND MONTH(date)='.$current_month.' AND YEAR(date)='.$current_year.' ORDER BY date DESC');
while($res_timesheet=mysql_fetch_array($sql_timesheet)){
$projID=$res_timesheet['project'];
$taskID=$res_timesheet['task'];
$editableid=$res_timesheet['id'];
上面的查詢由
01:20 AM
01:25 PM
03:25 AM
03:40 AM
04:20 PM
排序時間,但我需要一個像
01:20 AM
03:25 AM
03:40 AM
01:25 PM
04:20 PM.
PLS輸出也幫助我在這個問題上
你不_actually_具有存儲爲'01:20 AM'時間值,你...? – CBroe 2013-03-20 11:00:09
做*** NOT ***在varchar列中存儲時間。使用'TIME'數據類型。 – 2013-03-20 11:27:40
@a_horse_with_no_name即使我嘗試過但沒有解決方案,直到現在,很奇怪請幫助 – Basky 2013-03-21 12:57:17