I will echo Chris' comments about Armando's contribution and
generosity in sharing a solution that, if held back from the user
group, might have led (in our case) to some consulting compensation for
him in exchange for the answer. I'm glad that my question resulted in
a solution for all to share!
Kevin Byrnes
Chris Wagner wrote:
Congrats to Armando....
I saw that getDateandtime but the blinders went on with the time
part. I didn't need it so I decided (incorrectly i might add) i
couldn't use it. How foolish. Although I never would have gotten to
the total formula you did I am very impressed . This is why, I
think, these types of forums are great. Working together to make a
great program work better.
Again my hat is off to Armando.
Chris Wagner
[EMAIL PROTECTED]
wrote:
>I found that it works quite well for my purposes and
updating the
forumla to re-compute the age of the
> population as needed is a small price to pay
Kevin,
Check this formula out. It will require no update since the
year and month are being taken from the current date.
s2r(Substring(getDateandtime(),
Stringlength(GetDateandtime())-4,5)
)- r2i(field_1/10000) -1 + (if (Position(
"JanFebMarAprMayJunJulAugSepOctNovDec",
substring(GetDateAndTime(),5,3))+2)/3- s2i( substring(
trim(i2s(field_1)),5,2 ) )> 0 then 1 else 0 )
It will produce acceptable results with a month procession
The formula was constructed assuming your Date Of Birth field
is
numeric. If your DOB field is a string, the formula needs to be
slightly modified.
Cheers
Armando
-------- Original Message --------
Subject: Re:
[Maptitude] Computing a Person's Age from a Given Date
of
Birth
From: Kevin Byrnes
<[EMAIL PROTECTED]>
Date: Mon, April 04, 2005 9:28
am
To: [email protected]
Chris:
Notwithstanding my
appreciation for Armando's prompt & helpful response, I really
appreciate your programming suggestion ...I found that it works quite
well for my purposes and updating the forumla to re-compute the age of
the population as needed is a small price to pay.. When creating
the Age field, I used the Description sub-field to put in a "user
reminder" that the Age is computed as of a specified date (e.g. April
1, 2005). The _expression_ did return a warning message
about mixed data (i.e. string and integer) formats, suggesting the
possibility of truncated data; however it produces acceptable
results.
Thanks!
Kevin Byrnes
Chris Wagner wrote:
I
had
missed the part ..."and to recompute the age over time whenever
the file is re-opened"
The formula in the Edit>Fill
if
4-value(substring(I2S(dob),5,2)) <0 then
2004-value(left(string(DOB),4)) else
2005-value(left(string(DOB),4))
where the 4 in 'if
4-val'.... (is the current month) the '2004' is the last
year and '2005' is the current year
Should work although it may
not be the best or the fastest, and it does only work to the month
level... but it does run within Maptitude an not needing to export data
to another program type. You do need a field to accept the info...
such as Age.
5.5 million may take some time
to run. And each month it would have to be rerun to make it
accurate
I have not tried Armando's suggestion, and I am sure it
will work well... but if you look at my previous posts I haven't done
much with GISDK.... yet... ;-0
Chris
Wagner
Armando Scalise wrote:
> I suggest that
you do NOT do this type of
calculation in Maptitude.
Maybe it can really do it just fine
,
Indeed, it is possible to do it with great accuracy, as long
as you use
the right algorithm in GISDK
Attached is a macro
that I wrote to idnetify how many days were clientes
of the cable
company overdue in their bills.
It computes days between dates,
but it can be generalized to compute
almost any kidn of elapsed
time between two given moments (even to an
accuracy of
seconds, should you need it). Originally the macro was
written to loop through the records of a clietsn layer, and
popualte a
field in a separate table. I have wrapped it into
a separate UI to
show the functionality.
To try the
macro, follow the seutp model in the attached GIF file (note
that the macro name should be DBD, for "Days Between
Dates")
Cheers
Armando
>
Kevin: I suggest that you do NOT do this type of calculation in
> Maptitude. Maybe it can really do it just fine , but I would
do it in
> SAS, Stata, etc. So that you can use the code to
something similar
> later. I do the calculations in SAS
including date stuff because SAS
> is so good at doing this.
Then export to a DBF file and THEN take it
> into Maptitude
where it can do its thing. SAS handles dates very well
> to the
day. Functions are available for differences. All stat packages
> do these calculations with relative ease.
>
> Dick Hoskins
> WA State DOH
> Olympia,
WA
>
>
>
------------------------------------------------------------------------
>
*From:* Chris Wagner [mailto:[EMAIL PROTECTED]]
>
*Sent:* Friday, April 01, 2005 8:26 AM
>
*To:* [email protected]
>
*Subject:* Re: [Maptitude] Computing a Person's Age from a
Given
> Date of
Birth
>
> well to start with
if you don't need to get down to the
day
> where DOB =
19691123
>
> Add an Age
field
> Edit >Fill
Formula
>
2005-value(left(string(DOB),4)) where
2005 is the year
>
> as for months
and days .....
>
>
value(substring(I2S(dob),5,2))-4
where the -4 would =
>
April It will return a negative or positive on
if the month
> has passed or not.
>
>
Havn't figured out how to get that to convert into the age
but
> it can't be far
off
>
> Chris
Wagner
>
> Kevin Byrnes
wrote:
>
>> Does anyone in the
user group know of any functionality or
ability
>> within Maptitude to read
the system date and update a computed
"age"
>> field based on the difference
between the hard-coded Date of
>> Birth
on a
>> client record and the system
date? I really need this capability
to
>> process a huge (5.5 million
record) file and to recompute the
age
>>
over
>> time whenever the file is
re-opened.
>>
>> The Date of
Birth field is stored as an Integer (4 byte)
value,
>> with
the
>> format (e.g.) "19691123":
where 1969 = year, 11= month, 23 =
day
>>
>> Please advise or
assist if possible & many thanks in advance
to
>>
anyone
>> who can provide a
solution!
>>
>>
Thanks,
>> Kevin
Byrnes
>> Va Dept for the
Aging
>
>
>
------------------------------------------------------------------------
>
*Yahoo! Groups
Links*
>
>
* To visit your group on the web, go
to:
> http://groups.yahoo.com/group/Maptitude/
>
> * To
unsubscribe from this group, send an email
to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>
> * Your use of
Yahoo! Groups is subject to the Yahoo! Terms
of
>
Service <http://docs.yahoo.com/info/terms/>.
>
>
>------------------------------------------------------------------------
>
>No
virus found in this incoming message.
>Checked by AVG
Anti-Virus.
>Version: 7.0.308 / Virus Database: 266.8.4 - Release
Date: 3/27/2005
>
>
Yahoo! Groups Links
Yahoo! Groups Links
|