doing math with date function

From: "Johnson, Shaunn" <SJohnson6(at)bcbsm(dot)com>
To: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: doing math with date function
Date: 2002-03-18 15:52:23
Message-ID: 73309C2FDD95D11192E60008C7B1D5BB0452E0E3@snt452.corp.bcbsm.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Howdy:

Running Postgres 7.1.3 on RedHat Linux 7.2 kernel
2.4.7 - rev 10.

This has probably asked done a million times over,
but I can't seem to find the examples:

I want to do basic math on a data field (get the
difference in years) but can't find the example
to do it.

What I want is something like:

[pseudo code]

select
name,
dob,
case
when now() - dob > '21'
then 'legal'
when now() - dob > '18'
then 'no drinking'
else 'youths'
end as identify
from temp_table
;

[/pseudo code]

Are there any examples like this?

Thanks!

-X

Browse pgsql-general by date

  From Date Subject
Next Message Andre Lyra 2002-03-18 16:28:31 Re: [ODBC] ODBC
Previous Message Bruno Wolff III 2002-03-18 15:21:43 Re: Random Numbers/Letters