Jump to content
Sign in to follow this  
adyf

Date Calculation

Recommended Posts

I have created a date calculation field and want it to automatically calculate two years minus a day from another field:

i.e. Date: 25/12/2008 Calculation: 24/12/2010

If I add 730 days to the first field I sometimes get the right calculation but not always. I suspect leap years come into the equation but I'm not sure how to deal with this. Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

Technically, two years minus a day would be =

Date ( Month ( YourDate ) ; Day ( YourDate ) - 1 ; Year ( YourDate ) + 2 )

I say "technically", because there can be more that one correct answer to what is "two years minus a day" away from February 28/29 - it's largely a matter of preference. The above formula will return Feb. 28 if YourDate happens to be Feb 29, and Feb 27 when YourDate is Feb 28 (even if the the year of the result is a leap year).

Share this post


Link to post
Share on other sites

Thanks for the reply, that's exactly what I was after. Easy when you know how I guess.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site, you agree to our Terms of Use.