Go Back   PTI Marketing Technologies User Community > Software-Related Talk > FusionPro® VDP Creator

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 17th, 2010, 09:11 PM
Mike Mike is offline
Junior Community Member
 
Join Date: Oct 2010
Posts: 10
Default Date based Java

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.
Reply With Quote
  #2  
Old October 18th, 2010, 06:03 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: Date based Java

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:
Code:
// 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";
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #3  
Old October 18th, 2010, 10:43 PM
Mike Mike is offline
Junior Community Member
 
Join Date: Oct 2010
Posts: 10
Default Re: Date based Java

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
Reply With Quote
  #4  
Old October 19th, 2010, 05:17 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 870
Default Re: Date based Java

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:
Code:
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";
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #5  
Old October 19th, 2010, 04:15 PM
Mike Mike is offline
Junior Community Member
 
Join Date: Oct 2010
Posts: 10
Default Re: Date based Java

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.
Reply With Quote
Reply

Tags
date, date of birth, employment, rules

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:36 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.