By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,661 Members | 1,330 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,661 IT Pros & Developers. It's quick & easy.

Date Time Function / Age

P: n/a
Hi,
is there an easy way to get the Difference between 2 dates in Days... as
an integer?

age('date1','date2') results in x years y days or something similar.
but I would like to
have the result in number of days as an integer.

Thanks for your help

Alex

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 11 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Alex <al**@meerkatsoft.com> writes:
is there an easy way to get the Difference between 2 dates in Days... as
an integer?


Subtract 'em ...

regression=# select '2002-01-01'::date - '2001-01-01'::date;
?column?
----------
365
(1 row)
regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2

P: n/a
On Thu, Aug 28, 2003 at 23:09:44 +0900,
Alex <al**@meerkatsoft.com> wrote:
Hi,
is there an easy way to get the Difference between 2 dates in Days... as
an integer?

age('date1','date2') results in x years y days or something similar.
but I would like to
have the result in number of days as an integer.


If you subtract two dates (not timestamps) you will get an integer that is
the number of days difference in the dates.

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 11 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.