Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this SQL query,

SQL
("SELECT (month(bill_date) & ', ' & year(bill_date)) AS dt, " & _
"count(1) AS nbills, sum(amount) AS tamt, sum(iif(chk_free=1,amount,0)) AS pamt, " & _
"tamt-pamt AS totamt From rec_all Where iif(rec_ref is null,0,rec_ref)<>1 and rw = 0 and bill_date " & _
"between '" & Format(DTfrom(0).Value, "yyyy/mm/dd") & "' and '" & Format(DTfrom(1).Value, "yyyy/mm/dd") & "' and co_code='" & CoCode & "'" & _
"GROUP BY year(bill_date), month(bill_date)")


What I have tried:

After running this query error occurring
SQL
Incorrect syntax near 'SELECT (month(bill_date) & ', ' & year(bill_date)) AS dt, '.


Please help me...
Posted
Updated 2-Mar-17 18:34pm

1 solution

1. The & inside the "SELECT ... " should be +
2. You might also need to convert the month and year into varchar to avoid the error "Conversion failed when converting the varchar value '3, ' to data type int."

Example:

SQL
SELECT CONVERT(VARCHAR(2),MONTH(bill_date)) +', ' + CONVERT(VARCHAR(4),YEAR(bill_date))
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900