pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedcount number of weeks??
2+ messages / 2 participants
[nested] [flat]
* count number of weeks??
@ 2001-03-05 10:55 rocael@usa.net
0 siblings, 1 reply; 2+ messages in thread
From: rocael@usa.net @ 2001-03-05 10:55 UTC (permalink / raw)
To: pgsql-sql
Hi all!
I wonder how in PG7.0.2 I can count the number of weeks from a date field that
I have in a table, lets say:
table trial has in its fields start_date as sysdate(), and now I want to do a
select that will give me the number of weeks from now [sysdate()] to the
start_date.
Thanks for the help!
Rocael.
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: count number of weeks??
@ 2001-03-06 02:14 Christopher Sawtell <csawtell@xtra.co.nz>
parent: rocael@usa.net
0 siblings, 0 replies; 2+ messages in thread
From: Christopher Sawtell @ 2001-03-06 02:14 UTC (permalink / raw)
To: rocael@usa.net; pgsql-sql
On Tue, 06 Mar 2001 06:55, rocael@usa.net wrote:
> Hi all!
> I wonder how in PG7.0.2 I can count the number of weeks from a date
> field that I have in a table, lets say:
>
> table trial has in its fields start_date as sysdate(), and now I want to
> do a select that will give me the number of weeks from now [sysdate()]
> to the start_date.
chris=# select (select date('3 May 2001')-date(CURRENT_TIMESTAMP))::float8
/ 7.0 as "Weeks Till Start";
Weeks Till Start
------------------
8.28571428571429
(1 row)
chris=# select (select date('3 May 2001') - date(CURRENT_TIMESTAMP))::int
/ 7 as "Weeks Till Start";
Weeks Till Start
------------------
8
(1 row)
chris=# select version();
version
------------------------------------------------------------------------
PostgreSQL 7.1beta5 on i586-pc-linux-gnu, compiled by GCC egcs-2.91.66
(1 row)
That the sort of thing you wanted?
Don't know if it will work in 7.0.3, but upgrading is just a doddle.
PostgreSQL compiles faultlessly.
--
Sincerely etc.,
NAME Christopher Sawtell
CELL PHONE 021 257 4451
ICQ UIN 45863470
EMAIL csawtell @ xtra . co . nz
CNOTES ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz
-->> Please refrain from using HTML or WORD attachments in e-mails to me
<<--
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-03-06 02:14 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-03-05 10:55 count number of weeks?? rocael@usa.net
2001-03-06 02:14 ` Christopher Sawtell <csawtell@xtra.co.nz>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox