How to create function which returns persons age in years?
Function parameters:
ldDob - Day Of birth
ldDate - Day where age is returned
I tried
CREATE OR REPLACE FUNCTION public.age(date, date, out integer) IMMUTABLE AS
$_$
SELECT floor(INT($2::text::integer-$1::text::integer)/1);
$_$
On 5/14/07, Andrus [EMAIL PROTECTED] wrote:
How to create function which returns persons age in years?
[snip]
What's wrong with age()?
# select age('1879-03-14'::date);
age
--
128 years 2 mons
# select extract(year from age('1879-03-14'::date));
date_part
---
Andrus wrote:
How to create function which returns persons age in years?
Function parameters:
ldDob - Day Of birth
ldDate - Day where age is returned
I tried
CREATE OR REPLACE FUNCTION public.age(date, date, out integer) IMMUTABLE AS
$_$
SELECT
On Mon, 14 May 2007, Andrus wrote:
How to create function which returns persons age in years?
Look at the PostgreSQL docs for Date/Time Functions and Operators.
You'll find the syntax for AGE() there.
Rich
--
Richard B. Shepard, Ph.D. |The Environmental Permitting
Hi,
I believe I already mentioned something along these lines as an aside,
but this time I need it to work...
Look here:
template1= select age(now() + '01:30:00'::interval);
age
--
-17:02:41.247957
(1 row)
So, One and a half hour in the future is actually 17 days
template1= select age(now() + '01:30:00'::interval);
age
--
-17:02:41.247957
(1 row)
So, One and a half hour in the future is actually 17 days ago?
Interesting... Either I am doing something wrong, or postgres is, I have
my suspicions ;)
I guess the result
Alban Hertroys wrote:
Look here:
template1= select age(now() + '01:30:00'::interval);
age
--
-17:02:41.247957
(1 row)
So, One and a half hour in the future is actually 17 days ago?
Interesting... Either I am doing something wrong, or postgres is, I have
my
Berend Tober wrote:
Alban Hertroys wrote:
So, One and a half hour in the future is actually 17 days ago?
Interesting... Either I am doing something wrong, or postgres is, I have
my suspicions ;)
good-natured sarcasmYour suspicions are correct that you are doing, or
rather, understanding
Can someone tell me what I am missing here...
Thanks
Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio
radius=# BEGIN;
BEGIN
radius=# select age(tstamp, now()) from radacct limit 1;
age
--
03:37:08 ago
(1 row)
radius=# select
On Wed, 14 Mar 2001, Michael Fork wrote:
radius=# SELECT count(*) FROM radacct WHERE age(now(), tstamp) '6
months'::interval;
count
128378
(1 row)
-- Up until this points everything makes sense, however what follows
-- does not
radius=# SELECT count(*) FROM radacct
10 matches
Mail list logo