pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCreating timestamps in queries?
4+ messages / 3 participants
[nested] [flat]
* Creating timestamps in queries?
@ 2000-07-11 05:26 Rob S. <rslifka@home.com>
0 siblings, 2 replies; 4+ messages in thread
From: Rob S. @ 2000-07-11 05:26 UTC (permalink / raw)
To: pgsql-sql
Hi all,
I would like to say,
"select * from blah where stamp >= 7 days ago"
...where the "days ago" is calculated at query time; meaning that its not
hardcoded into the query as a date string. Is this possible?
TIA! =)
- Rob Slifka
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating timestamps in queries?
@ 2000-07-11 07:07 Patrik Kudo <kudo@partitur.se>
parent: Rob S. <rslifka@home.com>
1 sibling, 0 replies; 4+ messages in thread
From: Patrik Kudo @ 2000-07-11 07:07 UTC (permalink / raw)
To: Rob S. <rslifka@home.com>; +Cc: pgsql-sql
Hi Rob,
Try this:
select * from blah where stamp >= now()::date - 7;
I think it should work.
/Patrik Kudo
On Mon, 10 Jul 2000, Rob S. wrote:
> Hi all,
>
> I would like to say,
>
> "select * from blah where stamp >= 7 days ago"
>
> ...where the "days ago" is calculated at query time; meaning that its not
> hardcoded into the query as a date string. Is this possible?
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Creating timestamps in queries?
@ 2000-07-12 00:39 Frank Bax <fbax@execulink.com>
parent: Rob S. <rslifka@home.com>
1 sibling, 1 reply; 4+ messages in thread
From: Frank Bax @ 2000-07-12 00:39 UTC (permalink / raw)
To: pgsql-sql
I think you meant:
select * from blah where stamp >= now() - '7days'::interval;
You can also try:
select * from blah where age( now(), stamp ) < '7days'::interval;
Frank
At 09:07 AM 7/11/00 +0200, you wrote:
>Hi Rob,
>
>Try this:
>
>select * from blah where stamp >= now()::date - 7;
>
>I think it should work.
>
>/Patrik Kudo
>
>On Mon, 10 Jul 2000, Rob S. wrote:
>
>> Hi all,
>>
>> I would like to say,
>>
>> "select * from blah where stamp >= 7 days ago"
>>
>> ...where the "days ago" is calculated at query time; meaning that its not
>> hardcoded into the query as a date string. Is this possible?
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* RE: Creating timestamps in queries?
@ 2000-07-12 01:07 Rob S. <rslifka@home.com>
parent: Frank Bax <fbax@execulink.com>
0 siblings, 0 replies; 4+ messages in thread
From: Rob S. @ 2000-07-12 01:07 UTC (permalink / raw)
To: pgsql-sql
My friends, you are truly life-savers. Thanks very much!
How on Earth do you know this stuff? =) I saw all of these in the User's
Guide (re: now(), interval keyword, etc.), but in no way would figure this
was how they were put together!
Aside from the few in the FAQ, is there a list of commonly-done queries?
There are some for SELECT and whatnot, but maybe asking for that for these
far-out ones is too much.
Thanks again all ;)
- A very grateful Rob Slifka
> -----Original Message-----
> From: pgsql-sql-owner@hub.org [mailto:pgsql-sql-owner@hub.org]On Behalf
> Of Frank Bax
> Sent: July 11, 2000 5:40 PM
> To: pgsql-sql@postgresql.org
> Subject: Re: [SQL] Creating timestamps in queries?
>
>
> I think you meant:
>
> select * from blah where stamp >= now() - '7days'::interval;
>
> You can also try:
>
> select * from blah where age( now(), stamp ) < '7days'::interval;
>
> Frank
>
> At 09:07 AM 7/11/00 +0200, you wrote:
> >Hi Rob,
> >
> >Try this:
> >
> >select * from blah where stamp >= now()::date - 7;
> >
> >I think it should work.
> >
> >/Patrik Kudo
> >
> >On Mon, 10 Jul 2000, Rob S. wrote:
> >
> >> Hi all,
> >>
> >> I would like to say,
> >>
> >> "select * from blah where stamp >= 7 days ago"
> >>
> >> ...where the "days ago" is calculated at query time; meaning
> that its not
> >> hardcoded into the query as a date string. Is this possible?
> >
> >
> >
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2000-07-12 01:07 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-07-11 05:26 Creating timestamps in queries? Rob S. <rslifka@home.com>
2000-07-11 07:07 ` Patrik Kudo <kudo@partitur.se>
2000-07-12 00:39 ` Frank Bax <fbax@execulink.com>
2000-07-12 01:07 ` Rob S. <rslifka@home.com>
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