jaredlee.exe
jaredlee.exe

Reputation: 81

Return integer value of age(date) function in Postgres

I would like to determine the number of days that an account has been open. Ideally, I would like to compare the return value to an integer(days). i.e

I would like to see if age(open_date) > 14

If anyone has any better ideas...

Thanks

Upvotes: 0

Views: 3076

Answers (1)

Vao Tsun
Vao Tsun

Reputation: 51456

Here is how you get the number of days comparing two dates:

SQL> select extract(day from now()-'2015-02-21'::timestamptz);
 date_part
-----------
       122
(1 row)

Upvotes: 1

Related Questions