Problem sending date to SQL date time field

Discussion in 'ASP .Net' started by Robin, Aug 4, 2004.

  1. Robin

    Robin Guest

    In an ASP.Net page when trying to send a VB.net datetime field into a SQL
    Server stored procedure parameter of type datetime the following error
    occurs.

    SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
    11:59:59 PM

    How can the data be converted? What format does the field need to be in?
    Robin, Aug 4, 2004
    #1
    1. Advertising

  2. DateTime objects are ByValue - so they are initalized to a value of
    DateTime.MinValue. If your DateTime object is still set to the initial value
    , then 1/1/1 will be sent to SQL. This is immediately rejected. You have to
    pass null (Nothing) as the value of the parameter or set a default -
    depending on your specific needs. THis may be what is causing the error.



    "Robin" <> wrote in message
    news:%...
    > In an ASP.Net page when trying to send a VB.net datetime field into a SQL
    > Server stored procedure parameter of type datetime the following error
    > occurs.
    >
    > SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
    > 11:59:59 PM
    >
    > How can the data be converted? What format does the field need to be in?
    >
    >
    Jeremy Samuel, Aug 4, 2004
    #2
    1. Advertising

  3. The data type is Date. Just make sure the value of the date is not #12:00:00# SQL Server sees this a Jan 1, 0001 and that is out of range.

    hope this helps,
    John

    "Robin" wrote:

    > In an ASP.Net page when trying to send a VB.net datetime field into a SQL
    > Server stored procedure parameter of type datetime the following error
    > occurs.
    >
    > SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999
    > 11:59:59 PM
    >
    > How can the data be converted? What format does the field need to be in?
    >
    >
    >
    =?Utf-8?B?Sm9obiBTaXZpbGxh?=, Aug 4, 2004
    #3
    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. David Hearn
    Replies:
    1
    Views:
    414
    David Hearn
    Sep 10, 2003
  2. gil
    Replies:
    1
    Views:
    158
  3. JP SIngh

    Date Time field in ASP/SQL Server

    JP SIngh, Aug 22, 2005, in forum: ASP General
    Replies:
    2
    Views:
    163
    Aaron Bertrand [SQL Server MVP]
    Aug 24, 2005
  4. Sound
    Replies:
    2
    Views:
    440
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    418
Loading...

Share This Page