ASP SQL query error with data types

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David McManus

    ASP SQL query error with data types

    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

    #2
    Re: ASP SQL query error with data types

    Hi

    Use this date format and no problems

    yyyymmdd

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

    where date='yyyymmdd'


    Mex



    "David McManus" <dave@TAKETHISO UTnqo.com> wrote in message
    news:uSgEJPhpEH A.1164@TK2MSFTN GP10.phx.gbl...[color=blue]
    >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.
    >[/color]


    Comment

    • David McManus

      #3
      Re: ASP SQL query error with data types

      Confused....

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

      D

      "Meelis Lilbok" <meelis.lilbok@ deltmar.ee> wrote in message
      news:%23g1%23wT hpEHA.3424@TK2M SFTNGP12.phx.gb l...[color=blue]
      > Hi
      >
      > Use this date format and no problems
      >
      > yyyymmdd
      >
      > Query = "SELECT title FROM tblContent WHERE starting = '" & date & "'"
      >
      > where date='yyyymmdd'
      >
      >
      > Mex
      >
      >
      >
      > "David McManus" <dave@TAKETHISO UTnqo.com> wrote in message
      > news:uSgEJPhpEH A.1164@TK2MSFTN GP10.phx.gbl...[color=green]
      >>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.
      >>[/color]
      >
      >[/color]


      Comment

      • Bob Barrows [MVP]

        #4
        Re: ASP SQL query error with data types

        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:[color=blue]
        > Confused....
        >
        > Could you tell me precisely where in my query you mean, please?
        >
        > D
        >
        > "Meelis Lilbok" <meelis.lilbok@ deltmar.ee> wrote in message
        > news:%23g1%23wT hpEHA.3424@TK2M SFTNGP12.phx.gb l...[color=green]
        >> Hi
        >>
        >> Use this date format and no problems
        >>
        >> yyyymmdd
        >>
        >> Query = "SELECT title FROM tblContent WHERE starting = '" & date &
        >> "'"
        >>
        >> where date='yyyymmdd'
        >>
        >>
        >> Mex
        >>
        >>
        >>
        >> "David McManus" <dave@TAKETHISO UTnqo.com> wrote in message
        >> news:uSgEJPhpEH A.1164@TK2MSFTN GP10.phx.gbl...[color=darkred]
        >>> 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.[/color][/color][/color]

        --
        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.


        Comment

        Working...