Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Harv 18 posts 38 karma points
    Jul 14, 2011 @ 15:06
    Harv
    0

    Error importing dates

    I'm trying to import some SQL Server data into Umbraco but I get the following error for half the rows:
    "Arithmetic overflow error converting expression to data type datetime. The statement has been terminated."

    What's happening is dates such as "2008-08-13" are being converted to "08-13-2008", i.e. from UK to US date formats so it obviously doesn't like it.

    Trouble is I don't know how to configure the import to fix the problem! Any ideas?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 14, 2011 @ 15:12
    Richard Soeteman
    0

    Hi,

    I assume you are using the 2.0 version? Click on the green plus sign then you can specify the date format and that format will be used to convert the string value to date and then it should import ok.

    Cheers,

    Richard

     

  • Harv 18 posts 38 karma points
    Jul 14, 2011 @ 15:29
    Harv
    0

    Firstly thanks for your prompt reply.

    Yes I am using 2.0 and I have been playing with the date format field but I still can't get it to work. Maybe I'm not using it properly, am I specifying of the format the incoming date, or the date structure I want to convert to, or something else?

    So an example date that I'm trying to import is "2008-08-13 00:00:00.000", I've tried "yyyy/MM/dd HH:mm:sss" and "dd/MM/yyyy HH:mm:sss" but I get the same error.

    What am I doing wrong?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 14, 2011 @ 15:32
    Richard Soeteman
    0

    Hi,

    It's the format you are importing from so my guess is you need to use "yyyy-MM-dd HH:mm:sss"

    Cheers,

    Richard

  • Harv 18 posts 38 karma points
    Jul 14, 2011 @ 16:22
    Harv
    0

    I've tried the following all resulting in the same error:

    yyyy-MM-dd HH:mm:sss
    yyyy-MM-dd HH:mm:ss
    yyyy-MM-dd


    Do you have any other ideas?

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 14, 2011 @ 16:28
    Richard Soeteman
    0

    Are you mapping against a fixed property (CreateDate etc) or a dynamic property?

    Thanks,

    Richard

  • Harv 18 posts 38 karma points
    Jul 14, 2011 @ 17:05
    Harv
    0

    I'm mapping against a dynamic property, but the problem occurs on both.

    I'm importing data onto the Blog 4 Umbrcaco document type 'Blog Post', field Post Date. I have tried to map to the 'Publish At' field as well but I get the same error.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 14, 2011 @ 21:03
    Richard Soeteman
    0

    Hi,

    I just ran a test and when I mapped against the create data, or publish date with the specified format, make sure to include the time option as well it did work. It could be that your sqlserver is displaying a format, but in reality is using another format.Maybe specifying the format using a cast in your sql server query can fix that issue? Only thing that is a bug is the post field. This is a default date field and is missing the option to specify the Dateformat. I will fix that tomorrow.

    Cheers,

    Richard

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Jul 15, 2011 @ 16:33
    Richard Soeteman
    1

    HI,

    A bit later than expected. I've created a hotfix which adds the date settings also to a date picker. I ran a few tests this morning and at first I got the same error as you had. When you have dates formatted with a single digit you should also specify a single digit in the formatting option. Best to explain by my weird looking test case.

    When I have a date like this _31_1_2011 13:01 you can't use _dd_MM_yyyy HH:mm you must use _d_M_yyyy HH:mm  this will pick up single and double digit date formats.

    Hope this fixes your issue, if not please let me know.

    Thanks,

    Richard

     

     

     

  • Harv 18 posts 38 karma points
    Jul 18, 2011 @ 14:42
    Harv
    0

    Hi,

    Yes that hotfix worked, I didn't have to provide any specific formatting it just worked with default settings :D

    Thanks for taking the time to look at this problem, I really appreciate it.

    Thanks

    H

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Nov 15, 2011 @ 17:31
    Richard Soeteman
    0

    Check this small blogpost when you run into formatting issues.

    Hope that helps,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft