Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6

    Question Unanswered: Synthax error converting datetime from character string

    Dear all,

    I have a problem while manipulating data from a table.
    The error says something like that "Synthax error converting datetime from character string".

    Here is the SQL Statement that i used in VB:
    ---------------------------------------------------------------------------
    RsSync.Open ("SELECT * FROM [DYNAMICS].[dbo].[MC00100] WHERE EXGTBLID = 'LBP_AVG' AND CURNCYID = 'LBP' AND '& NDate &' < convert(datetime, EXPNDATE, 3) AND '& NDate &' > convert(datetime, EXCHDATE, 3)"), Con, adOpenStatic, adLockReadOnly
    ---------------------------------------------------------------------------
    NDate is defined as date.
    Even without the convert method, it still generates the same error.

    Please can anyone help me with it?


  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    improper quoting

    change this --
    Code:
    '& NDate &'
    to this --
    Code:
    '"& NDate &"'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Sep 2007
    Location
    Lebanon
    Posts
    6

    Exclamation Thanks

    Yes Thanks man, this was mainly the problem!
    I am very grateful to you.

Posting Permissions

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