LaRetta Posted April 20, 2012 Posted April 20, 2012 (edited) I have a StartDate (date) and a Frequency (text) field. I want to calculate the dates of the next upcoming frequencies based upon perspective of today. Weeks, Months, Quarter, Biannual Triannual and Yearly. I know how to get these results but not based upon today. Seems I have to first compare where I am relative to the StartDate. The current StartDates are several years old and need to stay. Weekly: start date is 1/7/2000 so Friday. Today is Friday (and can't count) so it should produce 4/27/2012. Monthly: start date is 1/1/2000 and today is 4/20/2012 so it should produce 5/1/2012. Triannual: start date is 2/15/2000 the next would be 6/15/2012 (sorry, I had put biannual and I meant triannual) Quarter: start date is 1/15/2000 the next would be 7/15/2000 since 4/15/2012 has passed If the date result IS today, it should jump forward to next period. I guess I'm a bit tired. Help through it would be appreciated. ADDED: BTW, some consider triannual to be an invalid definition so to explain ... triannual means every four months. Edited April 20, 2012 by LaRetta
comment Posted April 20, 2012 Posted April 20, 2012 To be more specific: WEEKLY = StartDate + 7 * ( Div ( Get ( CurrentDate ) - StartDate ; 7 ) + 1 ) N-MONTHLY = Let ( [ today = Get ( CurrentDate ) ; elapsedMonths = 12 * ( Year ( today ) - Year ( StartDate ) ) + Month ( today ) - Month ( StartDate ) - ( Day ( today ) < Day ( StartDate ) ) ; elapsedIntervals = Div ( elapsedMonths ; N ) ] ; Date ( Month ( StartDate ) + N * ( elapsedIntervals + 1 ) ; Day ( StartDate ) ; Year ( StartDate ) ) ) 2
LaRetta Posted April 20, 2012 Author Posted April 20, 2012 (edited) Your hint did the trick and I performed a forehead slap! My resulting calcs were not as pretty (or efficient) as yours (and those two should DO replace all of mine as well) ... Thank you! I never cease to be amazed at your date-function capabilities. LOL. I love the multiplicity of this! What a nice wake-me-up! Edited April 20, 2012 by LaRetta
Recommended Posts
This topic is 4657 days old. Please don't post here. Open a new topic instead.
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 accountSign in
Already have an account? Sign in here.
Sign In Now