help wit dates
Author Message
help wit dates

Hi there...

I am using a small database that contains information
about 100 persons. Now I would want to get
Paradox for Windows to show how old they are. I haven't
found any way to solve this so I might need to use
ObjectPal ... I don't have the PDOXWIN-manuals.

Fri, 22 Nov 1996 20:14:31 GMT
help wit dates

: Hi there...

: I am using a small database that contains information
: about 100 persons. Now I would want to get
: Paradox for Windows to show how old they are. I haven't
: found any way to solve this so I might need to use
: ObjectPal ... I don't have the PDOXWIN-manuals.

It can be done with a query.

|birthday                        |
|_a,calc (today-_a)/365.25 as age|

Note that today() needs the parens in ObjectPal, but not in a query.
Date arithmetic returns the result in days, hence the division by 365.25.
Birthday must be defined as a date field.

Fri, 22 Nov 1996 21:34:17 GMT
help wit dates

Quote:
> |birthday                        |
> |_a,calc (today-_a)/365.25 as age|

Ah!, but that's not *exactly* correct. Suppose you have an application where
there is a specific cut off date, and you want to find those people who are
*strictly* at a certain age on that day. The above calculation can give an off
by one error, which is dependent on leap years.

I haven't found any simple way of solving this problem. If anyone knows
of one, then I'd be interested to here it. For now, I have accepted the
possibility of the error.

Mike

Mon, 25 Nov 1996 21:30:12 GMT
help wit dates

: > |birthday                        |
: > |_a,calc (today-_a)/365.25 as age|

: Ah!, but that's not *exactly* correct. Suppose you have an application where
: there is a specific cut off date, and you want to find those people who are
: *strictly* at a certain age on that day. The above calculation can give an off
: by one error, which is dependent on leap years.

: I haven't found any simple way of solving this problem. If anyone knows
: of one, then I'd be interested to here it. For now, I have accepted the
: possibility of the error.

:       Mike

Well, if you do an integer truncation of age, I believe it works ok.  The
error gets larger until leap year, then it catches up.  But you are
truncating it off anyway.  Besides, I use the above query for doing election
demographics.  So I only need to know ABOUT how old people are.:')  Don't
know what the original questioner is doing.  For my data, the fractional
error is the least of my worries.  The county clerk's file only carries the
year of birth to 2 digits, so I have to trap for people "younger" than 18.
Yes, there are a few people in my data set with ages less than zero...

What happens in a leap century?  We've only got a little while to figure
it out.  But then, I guess we'll be better off than the COBOL programmers:-)

Wed, 27 Nov 1996 12:26:48 GMT
help wit dates

: Hi there...

: I am using a small database that contains information
: about 100 persons. Now I would want to get
: Paradox for Windows to show how old they are. I haven't
: found any way to solve this so I might need to use
: ObjectPal ... I don't have the PDOXWIN-manuals.

If you have a date of birth in Date field form, do this:

var
Age     Smallint
Date1,
Date2   DateTime
endvar

Date1 = DateTime("0:0:0 am " + Today())
Date2 = DateTime("0:0:0 am " + DateofBirth)

Age = Date1.year() - Date2.year()

endmethod...

if you look in the ObjectPal Online help, you should find the formats
for DateTime and year(). I think this should work...if not at least it will
point you in the right direction.

--

->  Robert G. Hearn                  'Bitterness breeds irritation'   <-

->  ==Paintball is my life!==                        -Rush                    <-

Wed, 27 Nov 1996 22:08:43 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages