Return to site

Print the Month based on a Date Field

Business Problem:

Often times you might want to filter a report based on the Month of a specific date or you will need a field to display on a record based on a date field. This is great for formula concatenations or reporting purposes

Formula Rule Solution:

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 1, "January",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 2, "February",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 3, "March",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 4, "April",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 5, "May",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 6, "June",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 7, "July",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 8, "August",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 9, "September",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 10, "October",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 11, "November",

IF(

Month(datevalue(Any_Date_Field_Here__c)) = 12, "December",

NULL

))))))))))))

This is a relatively simple formula but let's break this down anyways. The Month() function takes a date field value and gives you the number representation of that date. Therefore, if you want to display the actual Month in words you need an additional statement. The Datevalue() function breaks a date field down further and allows Salesforce to turn the date into a number. So, when you have the Month(Datevalue()) functions together you can get a Number representation from the Month field.