Copied to clipboard

Flag this post as spam?

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


  • Dan 1288 posts 3921 karma points c-trib
    Jan 28, 2013 @ 12:42
    Dan
    0

    Extend datepicker range

    Hi,

    I have a datepicker property which I'm using for archiving historical dates.  I need to enter some very old dates in there (like, 1066) and it's fine to type these into the input field rather than selecting them from the calendar pop-up (which only goes back 10 years anyway).  However, even though saving these old dates seems to work, when reloading the content node the values haven't been saved.

    I don't know if this is something to do with the javascript calendar or if it's server-side in the date validation, but I wondered if anyone could suggest a solution to get my old dates to save correctly.

    I guess one solution would be to change the data type to a text input with custom regex validation, but I'd like to try to 'fix' the original date picker data type first if it's easy to do.

    Thanks

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 29, 2013 @ 12:54
    Lee Kelleher
    0

    Hi Dan,

    I'm having a little dig into the source-code... I'll let you know what I find out.

    Cheers, Lee.

  • Dan 1288 posts 3921 karma points c-trib
    Jan 29, 2013 @ 12:57
    Dan
    0

    Thanks Lee.  I've gone as far as the client-side stuff and can't see why jQuery UI would be interfering - it looks like a pretty much out-of-the-box implementation of the calendar picker.  I've extended the range in there to 2000 years but it doesn't seem to have made any difference at all to anything (though this could be because of client dependency or some kind of cache).  So I think it perhaps is the .NET validation anyway.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 29, 2013 @ 12:59
    Lee Kelleher
    1

    Dan, which database are you using?

    I'm testing this out with SQL CE and hit an error at the database level.

    Cheers, Lee.

  • Dan 1288 posts 3921 karma points c-trib
    Jan 29, 2013 @ 13:05
    Dan
    1

    Interesting - the error is just if you go beyond a certain date though, right (the picker works until you enter an ancient date then it errors)?  I'm using SQL Server 2012 here.

    Edit: Is it something to do with the SQL Server 'datetime' range: http://msdn.microsoft.com/en-us/library/aa258277(v=sql.80).aspx ?

  • Dan 1288 posts 3921 karma points c-trib
    Jan 29, 2013 @ 13:12
    Dan
    1

    Ah, this is probably it: http://stackoverflow.com/questions/511979/best-way-to-store-old-dates-in-sql-server.  Seems like SQL Server will only go back as far as 1753 (!?) using the datetime or smalldatetime data type.  There's mention in that post of a new data type in SQL 2008 called just 'date'.  I'm tempted just to use a text-box with regex validation rather than changing SQL data-types!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 29, 2013 @ 13:13
    Lee Kelleher
    100

    Bingo! The earliest date you can have is January 1, 1753. (Interesting subtext over on StackOverflow)

    Sure enough if you enter "1752-12-31", the textbox/date-picker will empty.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 29, 2013 @ 13:16
    Lee Kelleher
    0

    I wouldn't recommend changing the column types in the database, who knows what else that might break. :-)

    Your solution of a regex textbox will work fine.

    A proper solution would be to store the date/time as a string (in the Nvarchar column) ... with the UI just handling the jQueryUI date-picker.  Maybe that's a future uComponents feature? ;-)

    Cheers, Lee.

  • Dan 1288 posts 3921 karma points c-trib
    Jan 29, 2013 @ 13:17
    Dan
    0

    Fantastic, thanks Lee.  At least I know it goes beyond Umbraco level now.  Learn something new every day!

    Perhaps this is the birth of the uComponents 'Ancient date picker' data-type ;)

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jan 29, 2013 @ 13:34
    Lee Kelleher
    0

    Read up a little more about it... looks like "datetime2" is the recommended type for dates in SQL Server 2008+. However SQL CE only supports the old "datetime", so that rules out any support across the board.  (MySQL's "datetime" doesn't have the 1753 limitation)

Please Sign in or register to post replies

Write your reply to:

Draft