0

I am using a connection to a CSV file to get the information in a XLS macro file and I am having the issue with this query:

DataQuery = "SELECT [LastName], [FirstName], [BadgeNum], IIF(IsNull([CaseDocs]), 0, [CaseDocs]),IIF(IsNull([CallCount]), 0, [CallCount]),  IIF(IsNull([DocRate]), 0, [DocRate])" & _
        "FROM [" & DataFileName & ".csv] WHERE CallCenterDescription='ECA' AND [LastName] LIKE '" & Sheets(1).Range("G1").Value & "%' AND DATEDIFF(dd,CONVERT(date, CONVERT(varchar(8), [Date]), 112),getdate())  <= " & Sheets(1).Range("G2").Value & ""

the problem is AND DATEDIFF(dd,CONVERT(date, CONVERT(varchar(8), [Date]), 112),getdate()) <= " & Sheets(1).Range("G2").Value & "" in the where clause:Undefined CONVERT function

1 Answer 1

1

you use different syntax for the same clause

CONVERT(date, CONVERT(varchar(8), [Date]), 112)

maybe should be

DATEDIFF(dd, date, getdate())

or

DATEDIFF(dd, [Date], getdate())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.