Laravel SQL Server,Concat结果?

I would like to get an combined string with Laravel using DB:raw(). I am using a SQL Server 2012 in Backgroud, but i am unable to the the following string scheme.

mm-yyyy (for example, 11-2016)

Its working with:

DB::raw('CONVERT(varchar(2),DATEPART(MM, invoices.invoice_date),100) + CONVERT(varchar(4),DATEPART(YY, invoices.invoice_date),100) AS invoice_month'),

to get 112016, but when ill try with:

DB::raw('CONVERT(varchar(2),DATEPART(MM, invoices.invoice_date),100) + "-" + CONVERT(varchar(4),DATEPART(YY, invoices.invoice_date),100) AS invoice_month'),

ill get an fatal PDO Exception.

Any ideas?

Instead of double quotes around the dash, try it with two single quotes around the dash:

DB::raw('CONVERT(varchar(2),DATEPART(MM, invoices.invoice_date),100) + ''-'' + CONVERT(varchar(4),DATEPART(YY, invoices.invoice_date),100) AS invoice_month')