Format Year in OOTB Date Slider

We have been trying to change the default year format (y,yyy) in the OOTB date refiner. Can someone suggest how to

change it to (yyyy) and remove the "," in between?

April 11th, 2014 12:32pm

Hi,

According to your post, my understanding is that you wanted to change the default year format in the OOTB date refiner.

I recommend to add JavaScript to the page where the refiners are displayed.

You can add the JavaScript by adding a Content Editor Web Part, which you then hide from being displayed on the page.

More information:

Add JavaScript to a page to display refiners in the correct format

JavaScript: How to Remove All Commas From a Number

Removing comma for value with Javascript

Thanks,

Linda Li

Forum Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

Free Windows Admin Tool Kit Click here and download it now
April 14th, 2014 8:21am

Thanks for your reply. We tried that, however, the div id that contains the year is generated dynamically and the page contains comma in other places also. The range also may contain other years and the interval is also getting generated dynamically while dragging the slider. We are facing challenges here.
April 14th, 2014 8:29am

Hello there,

We struggled with this for a while as well. We are also using the Created and Modified dates as refiners and they look like this:

Modified Date Refiner

Yet all we can get from our own was this same result as you.

The solution to this was actually very simple. Although not very simple to find. Add OWSDATE to the end of your managed property. That's it! Our DocumentEffectiveDate managed property became DocumentEffectiveDateOWSDATE and with only that small change we got the same look as above. Here is a look at the refiner with both names: 

Obviously much more friendly display on the second one.

Now you will notice in this example that I had to add a 2 to the name. This is because SharePoint had already created a managed property for me called DocumentEffectiveDateOWSDATE. Funny thing is that it created it as a text property, so it could not be used for this refiner.

After renaming the property in the Refiners webpart, this works exactly like our users were hoping it would.

Hope this helps.

Free Windows Admin Tool Kit Click here and download it now
May 5th, 2014 12:43pm

Hello there,

We struggled with this for a while as well. We are also using the Created and Modified dates as refiners and they look like this:

Modified Date Refiner

Yet all we can get from our own was this same result as you.

The solution to this was actually very simple. Although not very simple to find. Add OWSDATE to the end of your managed property. That's it! Our DocumentEffectiveDate managed property became DocumentEffectiveDateOWSDATE and with only that small change we got the same look as above. Here is a look at the refiner with both names: 

Obviously much more friendly display on the second one.

Now you will notice in this example that I had to add a 2 to the name. This is because SharePoint had already created a managed property for me called DocumentEffectiveDateOWSDATE. Funny thing is that it created it as a text property, so it could not be used for this refiner.

After renaming the property in the Refiners webpart, this works exactly like our users were hoping it would.

Hope this helps.

May 5th, 2014 12:43pm

Hello there,

We struggled with this for a while as well. We are also using the Created and Modified dates as refiners and they look like this:

Modified Date Refiner

Yet all we can get from our own was this same result as you.

The solution to this was actually very simple. Although not very simple to find. Add OWSDATE to the end of your managed property. That's it! Our DocumentEffectiveDate managed property became DocumentEffectiveDateOWSDATE and with only that small change we got the same look as above. Here is a look at the refiner with both names: 

Obviously much more friendly display on the second one.

Now you will notice in this example that I had to add a 2 to the name. This is because SharePoint had already created a managed property for me called DocumentEffectiveDateOWSDATE. Funny thing is that it created it as a text property, so it could not be used for this refiner.

After renaming the property in the Refiners webpart, this works exactly like our users were hoping it would.

Hope this helps.

Free Windows Admin Tool Kit Click here and download it now
May 5th, 2014 12:43pm

Hello there,

We struggled with this for a while as well. We are also using the Created and Modified dates as refiners and they look like this:

Modified Date Refiner

Yet all we can get from our own was this same result as you.

The solution to this was actually very simple. Although not very simple to find. Add OWSDATE to the end of your managed property. That's it! Our DocumentEffectiveDate managed property became DocumentEffectiveDateOWSDATE and with only that small change we got the same look as above. Here is a look at the refiner with both names: 

Obviously much more friendly display on the second one.

Now you will notice in this example that I had to add a 2 to the name. This is because SharePoint had already created a managed property for me called DocumentEffectiveDateOWSDATE. Funny thing is that it created it as a text property, so it could not be used for this refiner.

After renaming the property in the Refiners webpart, this works exactly like our users were hoping it would.

Hope this helps.

May 5th, 2014 12:43pm

Alternate way to work around this would be to slightly modify the date refiner code from OOTB Year_FIlter_Slider.html in the Master page catalog Display Templates > Filters.  Temporarily alter the culture setting for number formatting in the display template and then change it back afterwards.

//In sliderInitCallback()

//Change the culture separator to prevent years from being formatted as integers, i.e. with commas. var cultureObject = Sys.CultureInfo.CurrentCulture; var nfObject = cultureObject.numberFormat;

var numSeparator = nfObject["NumberGroupSeparator"] //remove the comma separators. nfObject["NumberGroupSeparator"]="";

//...after rendering turn back the setting to avoid side effects down stream.

nfObject["NumberGroupSeparator"]=numSeparator;


There might be some cultures without , in the thousands, you could probably temporarily set it to one of those cultures and set back as well. 

Free Windows Admin Tool Kit Click here and download it now
April 27th, 2015 3:02pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics