Corey-Troy Posted March 30, 2009 Posted March 30, 2009 Case(IsEmpty(Date Inspected) or IsEmpty(Frequency); GetAsDate(""); Date(Month( Date Inspected); Day(Date Inspected);Year(Date Inspected)+Frequency)) I am using version 8 I have not used fmp for a while am a little rusty. The above code calculates a date from the date Inspected and add's the number of years to it and places the result into the field called Due date. However when i set it up i set the Frequency to be years instead of months, but i cannot seem to get the result to revert to add in months instead of years. So if the user puts today's date as the Inspection date, and 3 in the Frequency, the result should be 31/6/09, but i get 15/3/2012. How can i change it to months instead? Corey....
Lee Smith Posted March 31, 2009 Posted March 31, 2009 I think your example dates have a typo or two in them. Date (Month (InspectionDate); Day (InspectionDate); Year(InspectionDate)+Frequency) Lee
Corey-Troy Posted March 31, 2009 Author Posted March 31, 2009 The example dates the result should be 31/6/09, but i get 15/3/2012 should be 30/6/09. The 15/3/2012 is correct, as it was adding 3 years to today's date instead of months. I managed to get a rough & ready result by using this Case(IsEmpty(Date Inspected) or IsEmpty(Frequency); GetAsDate(""); Date(Month( Date Inspected); Day(Date Inspected);Year(Date Inspected)))+(Frequency*30.44) I am after an exact calculation for months instead of my crude (*30.44) bit to divide the Frequency years into months. Lee, that code you posted is the same as the code i posted ? Corey....
comment Posted March 31, 2009 Posted March 31, 2009 Try adding the frequency to the month element of the date, instead of the year.
Corey-Troy Posted March 31, 2009 Author Posted March 31, 2009 Thanks Lee. Easy as that, yet it was beyond me. Cheers Corey....
Lee Smith Posted March 31, 2009 Posted March 31, 2009 You mean comment, he beat me to the punch again. LOL Lee
Corey-Troy Posted March 31, 2009 Author Posted March 31, 2009 You mean comment, he beat me to the punch again. LOL Lee Ahh yes i did. Opps. Quick question: can a Script be run from a Calculation, or only a Calculation run from Script ? ie. If field [Due date] <= Today, then run a script to send an email. Corey....
mr_vodka Posted March 31, 2009 Posted March 31, 2009 You can use a check with an opening script. Find those with Due date <= Today and then loop through. BTW, if you upgrade to FM10, you can use SMTP email directly from FM without using an email client. You can also use script triggers to auto send the email when a user changes the date in the field or when going to a record, etc.
Recommended Posts
This topic is 6060 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