Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Unanswered: Date Query Trouble :(

    Hi guys I have looked around on Google but can't quite figure out why I ma getting this error...

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
    [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'.


    My Date field known as Trandate is Date/Time format and in my sql I have the following statement:

    Code:
    mysql = mysql +   "WHERE sldetail.[trandate] " 
     	mysql = mysql +   "BETWEEN #10/01/2005# AND #25/01/2005# "
    When I use this statement:
    Code:
    mysql = mysql +   "WHERE sldetail.[trandate] " 
     	mysql = mysql +   "BETWEEN '10/01/2005' AND '25/01/2005' "
    It brings up this:
    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
    [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value.


    Any comments and suggestions are welcome. Thank you.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    mysql requires yyyy-mm-dd format

    ... BETWEEN '2005-01-10' AND '2005-01-25'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2006
    Posts
    2
    Thank you champ works peachy now. I didn't realise that dates had to be done via that format.

    Thanks again

Posting Permissions

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