本文介紹了Laravel 簡(jiǎn)單月份選擇的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問題描述
我嘗試從日期字段fechas"(日期時(shí)間類型)中檢索月份,其中使用 SQL 子句 MONTH 進(jìn)行測(cè)試不起作用...感謝回復(fù)
y tried retrieve month from date field "fechas" (datetime type) where testing with SQL clause MONTH not works... thanks for replies
$data = DB::table("ordenes")
->select(array('*', DB::raw('((cant_ped)*(precio_unit)) as sum_pedidos'), DB::raw('((cant_pend)*(precio_unit)) as sum_pends'), DB::raw('((cant_rec)*(precio_unit)) as sum_recibidos'), DB::raw('(((cant_pend)*(precio_unit)) + ((cant_rec)*(precio_unit))) as sum_importe')))
->where('cod_prov', '<>', 0)
///////////// line ERROR
->where('MONTH(fecha)', '=', '06')
///////->where('MONTH(fecha)', '=', '2014-06-20') ///test OK
->groupBy('cod_prov')
->skip(Input::get("jtStartIndex"))
->take(Input::get("jtPageSize"))
->get();
推薦答案
你可以使用隱藏 gem whereMonth
:
You could use the hide gem whereMonth
:
DB::table("ordenes")
->whereMonth('fecha', '=', '06')
->get();
我強(qiáng)烈建議您閱讀 Builder.php 源代碼以搜索其他 gem.:)https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Query/Builder.php
I highly recommend to you read the Builder.php source to search for another gems. :) https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Query/Builder.php
這篇關(guān)于Laravel 簡(jiǎn)單月份選擇的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!