我有一個帶有生日日期字段的聯繫表。Cakephp如何僅按日期和月份排序
現在我想在下週內顯示生日的列表。我可以展示它,但訂單是基於年份。
如何訂購數據,僅基於月份和日期?
$sideBarTaskSuggestion =
$this->Project->Contact->find('all', array(
'conditions' => array(
'Contact.group_id' => $this->Session->read('Auth.User.group_id'),
'Contact.birthdate NOT' => null,
'AND' => array(
array('Contact.birthdate NOT' => null),
array('Contact.birthdate + INTERVAL EXTRACT(YEAR FROM NOW()) -
EXTRACT(YEAR FROM Contact.birthdate) YEAR <=' => date('Y-m-d',
strtotime('+1 week'))),
array('Contact.birthdate + INTERVAL EXTRACT(YEAR FROM NOW()) -
EXTRACT(YEAR FROM Contact.birthdate) YEAR >=' => date('Y-m-d')),
)
),
'order' => 'Contact.birthdate DESC'
)
);
難道除了我誰也懶得讀的問題時,有水平滾動條的要求? –
你有沒有嘗試在你的'AND'條件下做同樣的事情?具體來說:''order'=>'EXTRACT(從Contact.birthdate開始的月)DESC'' – iso27002
@DanBracuk修復水平滾動條 – Harts