Tharu perera Tharu perera - 1 year ago 166
MySQL Question

change default date format laravel sql query

I want to change date out put from following SELECT query to DD/MM/YYY format . pls advice.

this is what I tried so far

->select('time_sheets.progress',DATE_FORMAT('', "%d/%l/%Y") ,'role_users.role_id','roles.role_name')

Answer Source

Instead of using ->select you can use selectRaw to allow raw SQL query so you can use:

->selectRaw('time_sheets.progress, DATE_FORMAT(, "%d/%l/%Y"), role_users.role_id, roles.role_name');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download