ShowAll Questionssorted byDate Posted
Ramakrishnan Ayyanar

# Next Birthday formula field that respects Leap Day

Problems:

1)If DOB is Feb 29 Leap year.How to find next birthday for that particular date?

No Need Validation rule for this code.

End-of-century years 1700, 1800,1900,2100 these years are not leap year in these problems are resolved.........

To find the next Birthday formula

How to create......

step-1: create the custom field for Date of Birth----It's type-Date

step-2: create the formula field for Birthday ---It's type-Date

code:

if(
MONTH(ramki__DOB__c) = 2 &&
DAY(ramki__DOB__c) = 29 ,
DATE(IF(Year(today())<=Year(ramki__DOB__c),
Year(ramki__DOB__c),
IF(
OR(MOD(Year(today())+4-MOD(Year(today()),4),400)=0,
AND(MOD(Year( today())+ 4-MOD(Year(today()),4),4)=0,
MOD(Year(today())+ 4-MOD(Year( today()),4),100)<>0)),
Year(today())+ 4-MOD(Year( today()),4),
Year(today())+ 8-MOD(Year( today()),4))
),
MONTH(ramki__DOB__c),DAY(ramki__DOB__c)),
if(Year( today()) <= Year( ramki__DOB__c)  ,
DATE(Year(ramki__DOB__c),MONTH(ramki__DOB__c),DAY(ramki__DOB__c)) ,
IF (DATE (YEAR(TODAY()),MONTH(ramki__DOB__c),DAY(ramki__DOB__c)) > TODAY(),
DATE (YEAR(TODAY()),MONTH(ramki__DOB__c),DAY(ramki__DOB__c)),
DATE (YEAR(TODAY())+1,MONTH(ramki__DOB__c),DAY(ramki__DOB__c))
)))

it's correctly worked for leap year dates.......
this is code for find the next Birthday friends......

Easily Calculate Age:

create formula field -------(Number)

Age=YEAR( ramki__BirthDay__c) - YEAR(ramki__DOB__c)
----
softramki@gmail.com
+919944112175
Ashish_SFDC
Hi ,

There is a article as well,

http://help.salesforce.com/apex/HTViewSolution?id=000004939&language=en_US

Regards,
Ashish
Ramakrishnan Ayyanar
Ashish_SFDC@

if the DOB-->29-2-2012 means the next birthday is 29-2-2016

End-of-century years 1700, 1800,1900,2100 these years are not leap year.

these type of problems are resolved.