Results 1 to 2 of 2
  1. #1
    Join Date
    May 2002

    Unanswered: syntax or data type problem

    Actually, what I'm trying to do is fix this syntax error:
    "syntax error(missing operator) in query expression'qryRGAqtr![Date] = 2Q 2000'."
    my SQL statement:
    sqlstate = "SELECT qryRGAqtr![Date],qryRGAqtr![Apple],qryRGAqtr![Other],"
    sqlstate = sqlstate & "qryRGAqtr![Apple %],qryRGAqtr![Other %] FROM qryRGAqtr"
    sqlstate = sqlstate & " WHERE qryRGAqtr![Date] = " + startdate + " ;"

    I have a field in my query called "Date". The query is based on a table and "Date" has date/time data type but I had to convert the "Date" to a different date format, I think by doing to I have changed the "Date" date/time data type to text and stored that into the query. Is that correct?
    If so, I would need to find out the "Date" date type in the query so it will match to the the variable which contains the value of a textbox in my SQL statement.

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    the problem is that 2Q 2000 is a character string and so should have quotes around it

    but it goes deeper than that

    if you want to pull quarters out of a date/time column, you should be using the DATEPART function, rather than formatting

    select something
    from yourtable
    where year(datecolumn) = 2000
    and datepart("q",datecolumn) = 2


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts