Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2002
    Posts
    2

    Unanswered: Converting from nvarchar to datetime

    Hrmm.. Ok, I don't know that much about SQL-Server, being an ASP-developer myself, but I have a problem. I have a field, nvarchar-format, containing dates in UK format, like 'dd/mm/yyyy'. Now I want to convert this to datetime format, since I have to sort by this column, but when I try to convert I get an error message: "Arithmetic overflow error converting expression to data type datetime.".

    I could solve this ASP-style, by writing a function that read every value from the database, converted the textstring to a mm/dd/yyyy format, and then try to convert again. But I'd rather not.. Does anyone have a better idea on how to solve this?

    Thanks..

    /Magnus

    Edit:
    I wrote an asp-thingy that converts the date to American format, and after that I can convert the field to datetime in Enterprise Manager, and it turns up as UK dates. Weird, but works. Thanks anyway..
    Last edited by Magnus; 04-11-02 at 09:43.

  2. #2
    Join Date
    Apr 2002
    Posts
    2

    Convert

    Try this
    Select CONVERT (datetime, '28/01/2002',103)

  3. #3
    Join Date
    Apr 2002
    Posts
    2

    Convert

    Try this
    Select CONVERT (datetime, '28/01/2002',103)

Posting Permissions

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