Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Admin > Re: how to get ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 4977 of 5167
Post > Topic >>

Re: how to get a number of seconds in some interval ?

by pgsql@[EMAIL PROTECTED] (Shane Ambler) May 13, 2008 at 06:12 PM

Scott Marlowe wrote:

> True.  But that's only because it doesn't have a date to work against.
>  If you run:
> 
> select '2007-02-01 12:00:00'::timestamp + '1 month'::interval;
> you get: 2007-03-01 12:00:00
> 
> If you run:
> select '2007-03-01 12:00:00'::timestamp + '1 month'::interval;
> you get:  2007-04-01 12:00:00
> 
> Then, if we run:
>  select ('2007-03-01 12:00:00'::timestamp + '1 month'::interval) -
> '2007-03-01 12:00:00'::timestamp;
> we get: 31 days
> 
> But if we run:
>  select ('2007-02-01 12:00:00'::timestamp + '1 month'::interval) -
> '2007-02-01 12:00:00'::timestamp;
> we get: 28 days
> 
> So, I'm not sure how many days a month has.

Try looking at a calendar.;-)

You will find that these are the exact days between the two dates. Feb 
has 28 days, so 1st of feb plus 1 month puts you at 1st of march

march has 31 days so 1st of march plus 1 month puts you at 1st of april.

Try a leap year -

select ('2008-02-01 12:00:00'::timestamp + '1 month'::interval) - 
'2008-02-01 12:00:00'::timestamp;
  ?column?
----------
  29 days
(1 row)


-- 

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @[EMAIL PROTECTED]
 http://Sheeky.Biz

-- 
Sent via pgsql-admin mailing list (pgsql-admin@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
 




 9 Posts in Topic:
how to get a number of seconds in some interval ?
julius@[EMAIL PROTECTED]   2008-05-12 16:44:16 
Re: how to get a number of seconds in some interval ?
achill@[EMAIL PROTECTED]   2008-05-12 17:24:38 
Re: how to get a number of seconds in some interval ?
achill@[EMAIL PROTECTED]   2008-05-12 18:01:34 
Re: how to get a number of seconds in some interval ?
tgl@[EMAIL PROTECTED] (T  2008-05-12 11:09:11 
Re: how to get a number of seconds in some interval ?
julius@[EMAIL PROTECTED]   2008-05-13 09:20:09 
Re: how to get a number of seconds in some interval ?
achill@[EMAIL PROTECTED]   2008-05-13 09:56:50 
Re: how to get a number of seconds in some interval ?
pgsql@[EMAIL PROTECTED]   2008-05-13 18:12:41 
Re: how to get a number of seconds in some interval ?
tgl@[EMAIL PROTECTED] (T  2008-05-13 10:15:27 
Re: how to get a number of seconds in some interval ?
scott.marlowe@[EMAIL PROT  2008-05-13 02:48:32 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Aug 21 22:35:54 CDT 2008.