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

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

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

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. Chris Berg
    Replies:
    0
    Views:
    1,079
    Chris Berg
    Oct 27, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,786
    Michael Borgwardt
    May 30, 2004
  3. Keith Cochrane
    Replies:
    2
    Views:
    849
    Keith Cochrane
    Aug 6, 2006
  4. flamesrock
    Replies:
    8
    Views:
    806
    Hendrik van Rooyen
    Nov 24, 2006
  5. Summu82
    Replies:
    5
    Views:
    1,127
    Richard Heathfield
    Jun 7, 2006
  6. David Hearn
    Replies:
    1
    Views:
    531
    David Hearn
    Sep 10, 2003
  7. gil
    Replies:
    1
    Views:
    263
  8. JP SIngh

    Date Time field in ASP/SQL Server

    JP SIngh, Aug 22, 2005, in forum: ASP General
    Replies:
    2
    Views:
    283
    Aaron Bertrand [SQL Server MVP]
    Aug 24, 2005
Loading...