Support the ongoing development of Laravel.io →
posted 10 years ago
Database

Hi guys i search in forum but not find a solution for this.

I need calculate age of a person from date field mysql with format xxxx-xx-xx into query builder

i have this code

DB::table('users as U') ->leftJoin('infomodelos as I', 'I.id_fk', '=', 'U.id') ->leftJoin('region as R', 'R.REGION_ID', '=', 'I.region') ->leftJoin('imagenes as IM', 'IM.id_fk', '=', 'U.id') ->where('U.perfil', 1) ->where('U.role_id', 2) ->where('I.sexo', 0) ->where('IM.perfil', 1) ->select('U.id as id', 'U.nombre as nombre', 'U.apellido as apellido', 'I.nacimiento as edad', 'R.REGION_NOMBRE as region', 'I.disponibilidad as disponibilidad', 'IM.nombre as imagen') ->get();

Thanks!!

Last updated 3 years ago.
0

Look at Carbon package

Last updated 3 years ago.
0

Thanks pogachar!!

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.