Lexical error when selecting data with date value in where clause


Hello, I'm attempting to execute the attached statement but keep getting the following error:

ERROR [3700] [AR System ODBC Driver]Expected lexical element not found: )

If I remove the date parameter the query executes propely. What do I need to do in order to refine my select statement to include date?
Dim RemedyLast As String = "2011-10-04 13:36:02.107"
        Dim tsdate = "{ ts '" + Format$(RemedyLast, "yyyy-MM-dd HH:mm:ss.ff") + "' }"

        ' Set up query string
        Dim CmdString As String = "SELECT ""Contact Name"", ""Contact Phone"", ""Create-date"", ""Div."", ""ETA Timestamp"", """ & _
        "Last-modified-by"", ""Modified-date"", ""Onsite Timestamp"", Priority, ""Problem Descr" & _
        "iption"", ""Record-Id"", Resolution, ""Service Status"", ""Site ID"", Status, ""Symptom " & _
        "Type"", ""Vendor Name"", ""Vendor Notify Timestamp"", ""Budget Line Item #"", ""Bill to " & _
        "Account #"", Log, ""Critical Notes"" FROM ISD ISD WHERE ((""Vendor Name"" = 'me') or (""Vendor Name"" = 'me-l') or (""Vendor Name"" = 'me-mn') or (""Vendor Name"" = 'me-tn')) AND (""Modif" & _
        "ied-date"" >= " + tsdate + " )"

Open in new window

gogetsomeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ajexpertCommented:
Can you try
Dim RemedyLast As String = "2011-10-04 13:36:02.107"
        Dim tsdate = "{ ts '" + Format$(RemedyLast, "yyyy-MM-dd HH24:mm:ss.ff") + "' }"

        ' Set up query string
        Dim CmdString As String = "SELECT ""Contact Name"", ""Contact Phone"", ""Create-date"", ""Div."", ""ETA Timestamp"", """ & _
        "Last-modified-by"", ""Modified-date"", ""Onsite Timestamp"", Priority, ""Problem Descr" & _
        "iption"", ""Record-Id"", Resolution, ""Service Status"", ""Site ID"", Status, ""Symptom " & _
        "Type"", ""Vendor Name"", ""Vendor Notify Timestamp"", ""Budget Line Item #"", ""Bill to " & _
        "Account #"", Log, ""Critical Notes"" FROM ISD ISD WHERE ((""Vendor Name"" = 'me') or (""Vendor Name"" = 'me-l') or (""Vendor Name"" = 'me-mn') or (""Vendor Name"" = 'me-tn')) AND (""Modif" & _
        "ied-date"" >= " + tsdate + " )"

Open in new window

0
gogetsomeAuthor Commented:
Thank you for your assistance Ajexpert. I tried, but got the same message.
0
ajexpertCommented:
Instead of using ODBC drivers, I guess you should be using ODP.NET drivers when using Oracle with .NET
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

ajexpertCommented:
Sorry for above 2 posts

Plz try this
Dim RemedyLast As String = "2011-10-04 13:36:02.107"
        Dim tsdate = "{ ts '" + Format$(RemedyLast, "yyyy-MM-dd HH:mm:ss.fff") + "' }"

        ' Set up query string
        Dim CmdString As String = "SELECT ""Contact Name"", ""Contact Phone"", ""Create-date"", ""Div."", ""ETA Timestamp"", """ & _
        "Last-modified-by"", ""Modified-date"", ""Onsite Timestamp"", Priority, ""Problem Descr" & _
        "iption"", ""Record-Id"", Resolution, ""Service Status"", ""Site ID"", Status, ""Symptom " & _
        "Type"", ""Vendor Name"", ""Vendor Notify Timestamp"", ""Budget Line Item #"", ""Bill to " & _
        "Account #"", Log, ""Critical Notes"" FROM ISD ISD WHERE ((""Vendor Name"" = 'me') or (""Vendor Name"" = 'me-l') or (""Vendor Name"" = 'me-mn') or (""Vendor Name"" = 'me-tn')) AND (""Modif" & _
        "ied-date"" >= " + tsdate + " )"

Open in new window

0
gogetsomeAuthor Commented:
Awesome, that did get me past that bug but now it is throwing this:
ERROR [S000] [AR System ODBC Driver]Data types are not appropriate for relational operation
0
ajexpertCommented:
Can you please remove date condition and check if your query is working fine...

May be this?
Dim RemedyLast As String = "2011-10-04 13:36:02.107"
        Dim tsdate = "{ ts '" + Format$(RemedyLast, "yyyy-MM-dd HH:mm:ss.fff") + "' }"

        ' Set up query string
        Dim CmdString As String = "SELECT ""Contact Name"", ""Contact Phone"", ""Create-date"", ""Div."", ""ETA Timestamp"", """ & _
        "Last-modified-by"", ""Modified-date"", ""Onsite Timestamp"", Priority, ""Problem Descr" & _
        "iption"", ""Record-Id"", Resolution, ""Service Status"", ""Site ID"", Status, ""Symptom " & _
        "Type"", ""Vendor Name"", ""Vendor Notify Timestamp"", ""Budget Line Item #"", ""Bill to " & _
        "Account #"", Log, ""Critical Notes"" FROM ISD ISD WHERE ((""Vendor Name"" = 'me') or (""Vendor Name"" = 'me-l') or (""Vendor Name"" = 'me-mn') or (""Vendor Name"" = 'me-tn'))

Open in new window

0
gogetsomeAuthor Commented:
Yes, that does work, but as soon as we try to use date in the where condition if fails with the lexical error.
0
ajexpertCommented:
Can you please tell us if you are storing fraction of seconds also in modified_date?
0
gogetsomeAuthor Commented:
The dates contain:

2011-10-04 13:36:02.107
0
ajexpertCommented:
You have to include TO_CHAR(MODIFIED-DATE, 'yyyy-MM-dd HH24:MI:SS.FF3') in the query
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gogetsomeAuthor Commented:
Yes, the date must be converted! Thank you for your assistance.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.