Why do you need to use Lower?
use Carbon for best portability
$pertemuans = Pertemuan::whereBetween('waktu',[$start, $end])->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi everyone,
I'm facing an issue where a query in Laravel, using both Eloquent and Query Builder, always returns empty results, even though the same query works perfectly fine when run directly in PostgreSQL (using DataGrip).
Here’s the code I’m using in Laravel: Using Eloquent:
$pertemuans = Pertemuan::query()
->whereRaw('LOWER(waktu) BETWEEN ? AND ?', [
'2024-09-23 02:41:18',
'2024-09-23 02:43:18'
])
->get();
Using Query Builder:
$pertemuans = DB::table('kelas.pertemuan')
->whereRaw('LOWER(waktu) BETWEEN ? AND ?', [
'2024-09-23 02:41:18',
'2024-09-23 02:43:18'
])
->get();
However, both queries return empty results, but when I try the same query directly in PostgreSQL, it works fine and returns the expected data:
SELECT * FROM "kelas"."pertemuan"
WHERE LOWER(waktu) BETWEEN '2024-09-23 02:41:18' AND '2024-09-23 02:43:18';
Additional Information:
Question: Why does this query work in PostgreSQL but always return empty data in Laravel? Has anyone encountered this issue before or have any suggestions for a fix?
Thank you so much for your help!
Please or to participate in this conversation.