error in running the select query with where statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • progvar
    New Member
    • Feb 2008
    • 40

    error in running the select query with where statement

    Hi!
    i am running the query but it is showing the error of syntax, i m accessing this table from sql server & my query is

    squery = "SELECT * FROM New_Rec where From_Date > = " & Format(DTPFrom & " 00:00:00", "dd/mm/yyyy HH:MM:SS AMPM") & " AND To_Date <= " & Format(DTPTo & " 23:59:59", "dd/mm/yyyy HH:MM:SS AMPM") & """"

    In this query FROM_DATE and TO_DATE are my column names AND DTPFrom & DTPTo are DTPicter .

    best regards
    varinder
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Hi
    [CODE=vb]
    squery = "SELECT * FROM New_Rec where From_Date>=#" & Format(DTPFrom & " 00:00:00", "dd/mm/yyyy hh:nn:ss AM/PM") & "# AND To_Date<=#" & Format(DTPTo & " 23:59:59", "dd/mm/yyyy hh:nn:ss AM/PM") & "#"[/CODE]

    Enclosed them with # for dates. I had replaced hh:mm:ss with hh:nn:ss.

    Rey Sean

    Comment

    • progvar
      New Member
      • Feb 2008
      • 40

      #3
      Hi
      this query is also showing the same error i,e syntax error near 7
      but i am not understanding



      Originally posted by lotus18
      Hi
      [CODE=vb]
      squery = "SELECT * FROM New_Rec where From_Date>=#" & Format(DTPFrom & " 00:00:00", "dd/mm/yyyy hh:nn:ss AM/PM") & "# AND To_Date<=#" & Format(DTPTo & " 23:59:59", "dd/mm/yyyy hh:nn:ss AM/PM") & "#"[/CODE]

      Enclosed them with # for dates. I had replaced hh:mm:ss with hh:nn:ss.

      Rey Sean

      Comment

      Working...