The birthdate field on the Contact object doesn’t show previous year and neither does it allow to switch back and forth the Years part easily.

Below example will show the last 100 years.

  1. Go to Setup -> App Setup -> Customize -> User Interface. Here make sure the ‘Show Custom Sidebar Components on All Pages’ is checked.
  2. Go to Setup -> App Setup -> Home Page Layouts. Make sure all your Home Page Layouts have the Messages & Alerts component checked.
  3. Go to Setup -> App Setup -> Home Page Components. Here, click edit for Messages & Alerts. In the textarea, copy and paste the javascript code below and save (it can just go below your normal Messages & Alerts, won’t show up on the actual page).
<script src="/js/dojo/0.4.1/dojo.js"></script>
<script src="/soap/ajax/11.1/connection.js" type="text/javascript"></script>
<script type="text/javascript">
var arYears = getYears();
function swapYears(){
	if(document.getElementById('calYearPicker') != null) {
		var select = document.getElementById('calYearPicker');
		var curValue = select.value;
		var parentx = select.parentNode;
		select = document.createElement('select');
		select.size = 1; = 'calYearPicker'; = 'calYearPicker';
	if(select != null) {
	for(x=0;x<100;x++) {
		select.options[x] = new Option(arYears[x], arYears[x], false, false);
function getYears() {
	sforce.sessionId = getCookie('sid');
	var out = [];
	var currentTime = new Date()
	var year = currentTime.getFullYear()
	try {
		for(x=0;x<100;x++) {
			out[x] = x+year-99;

	} catch(error) {
	return out;

Credits: Salesforce Community (

  • Rajit Nair

    Thanks so much! works like a charm!

  • Rajit Nair

    To get this working without any error, please remove the comments like:

    // generate dates for the last 100 years

    // Contact Birth day


  • Chirag Mehta

    Thanks Rajit for the correction. Updated post accordingly.

  • Mallesh

    its not working Mehta, could you please correct me

  • Chirag Mehta

    What error are you getting? Can you please check error console and see if there are any js errors.

  • Anshul Jain

    It did not work for me. I performed all the steps as given above.

    Please help.

  • Chirag Mehta

    Can you please check javascript Console and see if there are any errors?

  • shruthi

    It worked perfectly

  • Chirag Mehta

    great, enjoy :)

  • Michael Smith (@Force2be)

    Very nice!!

  • Chirag Mehta

    Thank you Michael!

  • Firoz Patel

    I have two date picker i need one standard and one customized ,
    1) 1st Datepicker range should be from 1980 to current and
    2)second Datepicker range should be from 2013 to current date
    how do I do?