ASP SQL query error with data types

Discussion in 'ASP General' started by David McManus, Sep 29, 2004.

  1. I am trying to use a query to filter SQL Server 2000 records by a date
    value.
    Here is relevant columns in my database table (tblContent):

    title [nvarchar]
    starting [smalldatetime]

    .... and here is my query:

    Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

    I've done exactly this query on numberous occassions in the past with no
    problems at all but this time I get the following error:

    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.

    What on earth is going on? I'm not using a char data type anywhere! I am
    doing all the initial development locally and I have just installed XP
    Service Pack 2. I realise it's unlikely, but that's the only thing I can
    possibly attribute it to. Or am I just missing something obvious?

    Anyone able to help, please?
    Thanks.
    David McManus, Sep 29, 2004
    #1
    1. Advertising

  2. Hi

    Use this date format and no problems

    yyyymmdd

    Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"

    where date='yyyymmdd'


    Mex



    "David McManus" <> wrote in message
    news:...
    >I am trying to use a query to filter SQL Server 2000 records by a date
    >value.
    > Here is relevant columns in my database table (tblContent):
    >
    > title [nvarchar]
    > starting [smalldatetime]
    >
    > ... and here is my query:
    >
    > Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"
    >
    > I've done exactly this query on numberous occassions in the past with no
    > problems at all but this time I get the following error:
    >
    > 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.
    >
    > What on earth is going on? I'm not using a char data type anywhere! I am
    > doing all the initial development locally and I have just installed XP
    > Service Pack 2. I realise it's unlikely, but that's the only thing I can
    > possibly attribute it to. Or am I just missing something obvious?
    >
    > Anyone able to help, please?
    > Thanks.
    >
    Meelis Lilbok, Sep 29, 2004
    #2
    1. Advertising

  3. Confused....

    Could you tell me precisely where in my query you mean, please?

    D

    "Meelis Lilbok" <> wrote in message
    news:%23g1%...
    > Hi
    >
    > Use this date format and no problems
    >
    > yyyymmdd
    >
    > Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"
    >
    > where date='yyyymmdd'
    >
    >
    > Mex
    >
    >
    >
    > "David McManus" <> wrote in message
    > news:...
    >>I am trying to use a query to filter SQL Server 2000 records by a date
    >>value.
    >> Here is relevant columns in my database table (tblContent):
    >>
    >> title [nvarchar]
    >> starting [smalldatetime]
    >>
    >> ... and here is my query:
    >>
    >> Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"
    >>
    >> I've done exactly this query on numberous occassions in the past with no
    >> problems at all but this time I get the following error:
    >>
    >> 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.
    >>
    >> What on earth is going on? I'm not using a char data type anywhere! I am
    >> doing all the initial development locally and I have just installed XP
    >> Service Pack 2. I realise it's unlikely, but that's the only thing I can
    >> possibly attribute it to. Or am I just missing something obvious?
    >>
    >> Anyone able to help, please?
    >> Thanks.
    >>

    >
    >
    David McManus, Sep 29, 2004
    #3
  4. http://www.aspfaq.com/show.asp?id=2313 vbscript
    http://www.aspfaq.com/show.asp?id=2040 help with dates
    http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion

    Bob Barrows

    David McManus wrote:
    > Confused....
    >
    > Could you tell me precisely where in my query you mean, please?
    >
    > D
    >
    > "Meelis Lilbok" <> wrote in message
    > news:%23g1%...
    >> Hi
    >>
    >> Use this date format and no problems
    >>
    >> yyyymmdd
    >>
    >> Query = "SELECT title FROM tblContent WHERE starting = '" & date &
    >> "'"
    >>
    >> where date='yyyymmdd'
    >>
    >>
    >> Mex
    >>
    >>
    >>
    >> "David McManus" <> wrote in message
    >> news:...
    >>> I am trying to use a query to filter SQL Server 2000 records by a
    >>> date value.
    >>> Here is relevant columns in my database table (tblContent):
    >>>
    >>> title [nvarchar]
    >>> starting [smalldatetime]
    >>>
    >>> ... and here is my query:
    >>>
    >>> Query = "SELECT title FROM tblContent WHERE starting = '" & date &
    >>> "'"
    >>>
    >>> I've done exactly this query on numberous occassions in the past
    >>> with no problems at all but this time I get the following error:
    >>>
    >>> 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.
    >>>
    >>> What on earth is going on? I'm not using a char data type anywhere!
    >>> I am doing all the initial development locally and I have just
    >>> installed XP Service Pack 2. I realise it's unlikely, but that's
    >>> the only thing I can possibly attribute it to. Or am I just missing
    >>> something obvious?
    >>>
    >>> Anyone able to help, please?
    >>> Thanks.


    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Sep 29, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anonymous
    Replies:
    0
    Views:
    1,443
    Anonymous
    Oct 13, 2005
  2. ramu
    Replies:
    2
    Views:
    316
    rlblaster
    Feb 20, 2006
  3. Replies:
    3
    Views:
    797
  4. Gary Roach
    Replies:
    0
    Views:
    105
    Gary Roach
    Sep 1, 2013
  5. Fábio Santos
    Replies:
    0
    Views:
    116
    Fábio Santos
    Sep 4, 2013
Loading...

Share This Page