Click here to Skip to main content
13,141,354 members (66,786 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
I am using this SQL query,

("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
Incorrect syntax near 'SELECT (month(bill_date) & ', ' & year(bill_date)) AS dt, '.


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

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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:

SELECT CONVERT(VARCHAR(2),MONTH(bill_date)) +', ' + CONVERT(VARCHAR(4),YEAR(bill_date))
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 3 Mar 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100