Here's my code:
$records = DB::connection('dw-billing')
->table('account_with_usage_no_zban')
->select([
DB::connection('dw-billing')->raw("FROM_DAYS(date_id) as `date`"),
'contact_email',
'license_key'
])
->whereBetween('date_id',[DB::connection('dw-billing')->raw("TO_DAYS('".Carbon::parse($fromdate)->toDateString()."')"),DB::connection('dw-billing')->raw("TO_DAYS('".Carbon::parse($todate)->toDateString()."')")])
->groupBy(['date','contact_email','license_key'])
->get();
Which I've confirmed using a listener builds the following sql statement:
select FROM_DAYS(date_id) as `date`, `contact_email`, `license_key` from `account_with_usage_no_zban` where `date_id` between TO_DAYS('2017-04-25') and TO_DAYS('2017-04-25') group by `date`, `contact_email`, `license_key`
But I get no records returned.
If I execute the query directly via the mysql client, I get the records I'm expecting (3)
Any ideas?