Gossamer Forum
Home : Products : DBMan : Customization :

Age Mod????

Quote Reply
Age Mod????
hi,
I have been reading lot of threads about "Age mods" that user enter their brithday (date ) into the record...when user view the record, it will show up the "age" instead of brithday. Also,people can enter the "age" instead of brithday to search on the record (like searching for age 16 - 24 ).
JPDeni have written some nice mods for it...but its kinda confusing which one i should use because there are more than one threads talking about this "Age mod".
Could any one tell me the exactly coding of "Age mod" that i use for the above situation ??
Any suggestion would be greatly apprciated
Quote Reply
Re: Age Mod???? In reply to
One big question: is there any chance that anyone who will be in your database will be more than 30 years old?


------------------
JPD






Quote Reply
Re: Age Mod???? In reply to
Thanks Smile
Yeah...most likely that some of user would be more than 30 years old
Quote Reply
Re: Age Mod???? In reply to
The reason I asked is that DBMan uses the Unix "time" to deal with dates. It works fine for any date since 1 Jan 1970, but not for any date prior to that.

I've developed a workaround, though, that uses a different method of converting dates. You can pick up the mod at http://www.jpdeni.com/.../date_translator.txt . (This isn't in the Resource Center yet. I still need to be sure it doesn't have any bugs in it. Are you willing to help me test it?)

While you install the mod, I'll work out again how to compute the age.


------------------
JPD






Quote Reply
Re: Age Mod???? In reply to
Thanks JPDeni,
I will get it installed it and tell you how it goes.
You have been very nice to me ,there is no reason why i dont help you...
Smile


Quote Reply
Re: Age Mod???? In reply to
ok..i just got the "U niversal Date T ranslator" mod installed.
What is next ? Smile
by the way, i use the "drop down menu" that u wrote to let user to choose the date.

Thanks


[This message has been edited by johnsonny (edited April 25, 2000).]
Quote Reply
Re: Age Mod???? In reply to
I'm going to need to find the other post from eoin so I can remember how to do this. My brain is definitely not working well this morning, so I'll have to get back to you when I find the other post. I still haven't caught up with the new posts from yesterday yet. Smile


------------------
JPD






Quote Reply
Re: Age Mod???? In reply to
If you want to print out a person's age in sub html_record (or sub html_record_long, if you're using the short/long display mod), after

my (%rec) = @_;

add

Code:
$Age = int((&date_to_unix(&get_date()) - &date_to_unix($rec{'BirthDate'}))/10000);

Change BirthDate to match the name of your birthdate field.

To search for records where the person is between one age and another age, you'll need to add two fields to your search form -- Age-gt and Age-lt.

(I think I have this worked out. Things get really confusing sometimes. Smile )

In sub query, in the db.cgi file, after

local (%sortby);

add

Code:
if ($in{'Age-gt'}) {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my $byear = $year - $in{'Age-gt'} + 1900;
++$day;
++$mon;
($day < 10) and ($day = "0$day");
($mon < 10) and ($mon = "0$mon");
$date = $byear . $mon . $day;
$in{'BirthDate-lt'} = &get_computed_date($date);
}
if ($in{'Age-lt'}) {
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $daylight) = localtime(time());
my $byear = $year - $in{'Age-lt'} + 1899;
++$mon;
($day < 10) and ($day = "0$day");
($mon < 10) and ($mon = "0$mon");
$date = $byear . $mon . $day;
$in{'BirthDate-gt'} = &get_computed_date($date);
}

Again, you'll need to change BirthDate to match your field name.

Try this out and see if it works.



------------------
JPD






Quote Reply
Re: Age Mod???? In reply to
THanks JPDeni!! , Smile

I will try it and tell you how it goes...

Smile

Quote Reply
Re: Age Mod???? In reply to
hi,
after i got the "Universal Date T ranslator" mod installed,no matter what formation of date i type to add a record,it just keep showing "Invalid date format"

Any idea???
Quote Reply
Re: Age Mod???? In reply to
Cool...it works now..
I just made a little bit mistake....
i setted "&get_date" as default for the "birth" field.....then got error..

Thanks for your time to write me this wonder mod, JPDeni

Smile
Quote Reply
Re: Age Mod???? In reply to
Yo,

I just gotta say that this mod works perfectly. You can see mine at work. Just sign up at:

http://thor.prohosting.com/~eoinc/cgi-bin/dbman/db.cgi?signup_form=1

johnsonny, can I see your one working?

Thank JP Smile

Eoin
i.am/eoin