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?
Technology Tips and News
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?
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.
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:
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.
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:
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.
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:
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.
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:
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.
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.