I'm trying to store some dates for a historic timeline using the datepicker.
I've come to the realisation that there are a few limits on this datatype and I'm hoping for some advice on how to remove those limits.
The first is Umbraco focused: the datepicker element appears to only let me go back as far as 1900-01-01 I'm guessing that there's a validation string somewhere that I can tweak to change this limit?
The second limit I'm aware of is the datetime datatype in SQL, which is how these dates are stored. Following https://msdn.microsoft.com/en-GB/library/ms187819.aspx I'm aware that the minimum date here is 1753, and this is still not low enough for my use case (1066 onwards)
Is there a way to make Umbraco use datetime2 as a database format?
My backup here is to use a textstring for these dates, but that is much more prone to content editor mistakes!
I discovered this problem last night on 7.2.6 and is still there after upgrading to 7.3.0.
Obviously it used to work and can still, as I have dates saved that are pre 1900 from using older versions, but can no longer enter a date before 1900. Is there any quick hack or something that I can do to fix this?
The only problem will occur after the Umbraco update, so better solution is to create Back Office "extension", "plugin", ... I don't know how it's called exactly.
A clean and easy way to implement Aghasi's suggestion is to create a new property editor that inherits from the standard datepicker. Just add a new class to your project, and put code like this in it:
using Umbraco.Core.PropertyEditors;
using Umbraco.Web.PropertyEditors;
namespace SedgwickCountyOrg.App_Plugins.HistoricalDatePicker.PropertyEditors
{
[PropertyEditor("HistoricalDate", "Historical Date", PropertyEditorValueTypes.Date, "datepicker", Icon = "icon-calendar")]
public sealed class HistoricalDatePropertyEditor : DatePropertyEditor
{
public HistoricalDatePropertyEditor() => DefaultPreValues.Add("minDate", "moment({y: 1800})");
}
}
Then you can add a new data type based on the HistoricalDate property editor, and use it in your document types.
Date Picker for pre 1900 dates
Hi Guys,
I'm trying to store some dates for a historic timeline using the datepicker.
I've come to the realisation that there are a few limits on this datatype and I'm hoping for some advice on how to remove those limits.
The first is Umbraco focused: the datepicker element appears to only let me go back as far as 1900-01-01 I'm guessing that there's a validation string somewhere that I can tweak to change this limit?
The second limit I'm aware of is the datetime datatype in SQL, which is how these dates are stored. Following https://msdn.microsoft.com/en-GB/library/ms187819.aspx I'm aware that the minimum date here is 1753, and this is still not low enough for my use case (1066 onwards)
Is there a way to make Umbraco use datetime2 as a database format?
My backup here is to use a textstring for these dates, but that is much more prone to content editor mistakes!
I discovered this problem last night on 7.2.6 and is still there after upgrading to 7.3.0. Obviously it used to work and can still, as I have dates saved that are pre 1900 from using older versions, but can no longer enter a date before 1900. Is there any quick hack or something that I can do to fix this?
Thanks a lot for any help anybody could offer?
Tom
My bodge for now is to store dates +2000 years.
eg:
The date 01-01-760 is entered in the interface as 01-01-2760
I then subtract 2000 on output.
Dirty, but it works for now!
Thanks. That won't work for me as already have hundreds of dates in the correct format!
There must be some 'fix' for it .. I'll have to look into it further.
The date settings applied within Bootstrap Date/time picker widget: https://github.com/Eonasdan/bootstrap-datetimepicker
It's located in
./Umbraco/lib/datetimepicker
directory.All you need is to change values of
minDate
andmaxDate
properties of$.fn.datetimepicker.defaults
object inbootstrap-datetimepicker.js
file.For instance I need range of dates 1800 - (now + 100 year). Then the
$.fn.datetimepicker.defaults
object should looks like the following:The only problem will occur after the Umbraco update, so better solution is to create Back Office "extension", "plugin", ... I don't know how it's called exactly.
The code should looks like the following:
Aghasi
A clean and easy way to implement Aghasi's suggestion is to create a new property editor that inherits from the standard datepicker. Just add a new class to your project, and put code like this in it:
Then you can add a new data type based on the HistoricalDate property editor, and use it in your document types.
is working on a reply...