D
D
dk-web2015-10-18 23:30:41
Laravel
dk-web, 2015-10-18 23:30:41

How to correct such request in Laravel?

$users = DB::table('users')->select(DB::raw('id,name,bday,DATEDIFF(
                 CONCAT(
                 YEAR(CURDATE()),
                 '-', MONTH(bday),
                 '-', DAY(bday)
                 ),
             CURDATE()
             ) AS daysto'))->whereBetween('daysto', [-10, 10])->get();

does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Defman21, 2015-10-18
@dk-web

You have an error in your code.

$users = DB::table('users')->select(DB::raw("id,name,bday,DATEDIFF(
                 CONCAT(
                 YEAR(CURDATE()),
                 '-', MONTH(bday),
                 '-', DAY(bday)
                 ),
             CURDATE()
             ) AS daysto"))->whereBetween('daysto', [-10, 10])->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question