Mike Posted October 18, 2010 Share Posted October 18, 2010 Hi, I love this program and need some help if possible with two issues: 1. Hire rules/code programmers: Is anyone interested in developing code for me as needed? It will take me ages to learn this program and I would like to be able to contract to a guru to create rules on an as-is-needed basis. Please let me know if this is posted in the wrong place: 2. Date based help: I have a D.O.B field and I need to run a rule that will: a) Look at the DOB files and calculate the current age in years. b) Return a text resource based on the age ie 0 - 16 = text resourceA 17 - 30 = text resourceB I am very greatful of any help that may be provided. Link to comment Share on other sites More sharing options...
esmith Posted October 18, 2010 Share Posted October 18, 2010 Hi Mike, and welcome to the forum. A couple of things: 1) FusionPro uses JavaScript (JS); not Java. Some senior engineers around here are quick to scold if you use the wrong terminology. 2) If you are looking for contract coders, there is a specific sub-forum for posting want-ads. However, there are several people who frequent these boards that will often offer solutions to your problems pro bono if you ask nicely and they have time to respond. 3) Since I have time today, here is my stab at your date solution: // modified code from http://forums.asp.net/t/1383686.aspx Date.prototype.YearsBetween = function(){ var intMilYear = 365.23 * 24 * 60 * 60 * 1000; var intMilDif = arguments[0] - this; var intYears = Math.floor(intMilDif/intMilYear); return intYears; } var dob = new Date(Field("DOB")); // YOUR FIELD in a standard date format var today = new Date(); var yearsBetween = dob.YearsBetween(today); // replace returned text strings with your text resources if (yearsBetween <= 16) return "Less than 17 years"; else if (yearsBetween <= 30) return "Between 17 and 30 years"; else return "More than 30 years"; Link to comment Share on other sites More sharing options...
Mike Posted October 19, 2010 Author Share Posted October 19, 2010 Thanks a million that worked perfectly. I have modified it to show back pages based on age. However how would I show ages between dates such as below: if (yearsBetween <= 16) return "Less than 17 years"; PERFECT if 17 - 40 return "17 - 40 years"; if 41 - 60 return "41 - 60 years"; else if (yearsBetween >= 61) return "Over 61"; else return "Over 61"; Your help is really appreciated Link to comment Share on other sites More sharing options...
esmith Posted October 19, 2010 Share Posted October 19, 2010 That should be relatively easy to figure out; even for a self-proclaimed amateur JavaScripter. You use the same logic that already exists in the code above and add more ELSE IF statements working from the lowest amount to the highest (so that the lower values return a value before testing a higher value). Note that in your post above, you do not need the final ELSE IF (Over 61) since it is captured in the last ELSE. In the above example, you would replace the last three lines of code with the following: if (yearsBetween <= 16) return "Less than 17 years"; else if (yearsBetween <= 40) return "Between 17 and 40 years"; else if (yearsBetween <= 60) return "Between 41 and 60 years"; else return "Over 60"; Link to comment Share on other sites More sharing options...
Mike Posted October 19, 2010 Author Share Posted October 19, 2010 Thanks for your help. This is a great community and I look forward to being able to give back in the future. Thanks again eric. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.