SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Knowledge is key 2 progression Tryst's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Converting NVARCHAR to datetime Problem

    Hi all,

    I am pulling my hair out of this error that I keep getting. I have a stored procedure that gets data from a database, with one of those fields being a NVARCHAR(10) which contains information on a date (10/01/2004 etc etc). In this stored procedure I am also pushing all these extracted data into a new database, but in this new database the field that is to contain the date is now a DATETIME field whose length is set to 8.

    WHen I try to put the NVARCHAR data into this DATETIME field I get the following error message.

    Code:
    Arithmetic overflow error converting expression to data type datetime.
    The statement has been terminated.
    The data in the nvarchar column is all like a normal data, so I was under the impression that this date would automatically convert to DATETIME when passing into the new database

    Tryst

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,270
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    you really should show the code

    we cannot guess what you mean by "put" the NVARCHAR data into the DATETIME field

    do you use the CONVERT function?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict markchivs's Avatar
    Join Date
    Oct 2004
    Location
    Malvern Hills, UK
    Posts
    233
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there any particular reason why your using an NVARCHAR data type to store your date? Especially if your dates are stored as xx/xx/xxxx - Just curious

    Quote Originally Posted by r937
    do you use the CONVERT function?
    Yeah it's a good bet you need to use it:




Bookmarks

Posting Permissions

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