+ Start a Discussion

Need help with calculating expiry date that handles leap year

hi i am trying create a formula field that calculates that expiry date from a start date and term


i got something like


startDate + terms * 30.4375


but it has some weird results? and does not handle leap years


anyone have a better formula :@


What are the datatypes of the fields that you are using?  Date, DateTime, Number, Picklist, etc.  What kind of result are your trying to display?  a Date, a DateTime, a Number?


the expiryDate is a date field


start date is a date field

terms is a number field measured in months i.e 1, 4, 12 etc..


i am trying to calculate the expiry date from start date and terms entered?


so if someone enters start date: 31/02/2011 terms: 1

then expiry date: 28/02/2011

and should handle leap years if possible :@


another example:

start date: 28/02/2011 terms:12

expiry date: 28/02/2012


ouch...  okay that one is not gonna be easy if you need to make adjustments for number of days in the month(28, 30, 31) and also factor in leap year.  


i think i'll handle this in apex will be easier