[SQL] Default timestamp value

2000-06-05 Thread Rob S.

As a precursor to this question, I read:

CREATE TABLE
Date/Time Types (and corresponding input/output)
Date/Time Functions

...but I still don't see how to have the default value of a timestamp to be
the time at which the individual record is inserted.  I just get the time I
created the table.  Specifically, what to put where the '?' is at.

... "TimeDate" TIMESTAMP DEFAULT ? ...

I tried 'now' and 'current' but it just makes the default value the time
when I create the table, and 'current' gives me the word 'current' back in
psql, so I imagine I'm not taking that in quite the right way =)  I can see
why it does this for both of these, althought in the docs, it says current
is current time, deferred, but I dunno what that means.

Any help or pointers to a nice resource?  IMHO, the PG docs are a great
reference, but not much in the way of terrific examples =)

- r





RE: [SQL] Default timestamp value

2000-06-05 Thread Rob S.

Thanks very much everyone!

> BTW, this *is* covered in the FAQ, see
>   http://www.postgresql.org/docs/faq-english.html#4.22

Ahh, but I did look at a FAQ! I just went back and checked the date, I guess
I shouldn't have just skimmed down the page: Last updated: Mon Oct 14
08:05:23 EDT 1996.  That's the last time I search for a FAQ before checking
the PG page. ;)

Thanks again everybody =)

- r




[SQL] Creating timestamps in queries?

2000-07-10 Thread Rob S.

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




RE: [SQL] Change type of column

2000-07-11 Thread Rob S.

I think this is in the FAQ.  I was reading it last nite and I believe
there's something in there that might be relevant.

- r

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
> Of Volker Paul
> Sent: July 11, 2000 12:32 AM
> To: [EMAIL PROTECTED]
> Subject: [SQL] Change type of column
>
>
> Hello,
>
> how can I change the type of a column, e.g. from varchar() to text?
> Or is it possible to drop (i.e. delete) a column without
> creating a new table from the old one but without that column,
> dropping the old table and renaming the old to the new?
>
> Thanks,
>
> Volker Paul
>




RE: [SQL] Creating timestamps in queries?

2000-07-11 Thread Rob S.

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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf
> Of Frank Bax
> Sent: July 11, 2000 5:40 PM
> To: [EMAIL PROTECTED]
> 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?
> >
> >
> >
>