Re: [GENERAL] CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP - Mailing list pgsql-general

From Jose Soares
Subject Re: [GENERAL] CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP
Date
Msg-id 38BBCB88.39ECAF85@sferacarta.com
Whole thread Raw
In response to CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP  ("sheila bel" <sheilabel@hotmail.com>)
List pgsql-general

sheila bel wrote:

> Hi all,
>
> I wanted to get some information about date and time
> stamps and examples of how to use them. In the User
> Manual I got referred to functions called CURRENT_DATE,
> CURRENT_TIME. I have been literally searching for
> hours to find more about them in all the PostgreSQL
> manuals, I've used ALL the search engines and did not
> find anything. If there is a reference to them they should
> be somewhere in there, right?
> I'm sorry but dear developers your manual is not user
> friendly at all :(
> A lot of time gets wasted on finding the information you
> need or not finding them at all.
>
> -Sheila

You ca use the niladics datetime functions:

               - CURRENT_DATE
               - CURRENT_TIME
               - CURRENT_TIMESTAMP

as  a column default value like:

CREATE TABLE mytb (
    mydt  DATE DEFAULT CURRENT_DATE,
    mytm TIME DEFAULT CURRENT_TIME,
    myts   TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

to insert a value into a column as in:

    INSERT INTO mytb (mydt) VALUES(CURRENT_DATE);

to compare two values as in:

    SELECT * FROM mytb WHERE mytm BETWEEN '1999-12-31 12:30:00' AND
CURRENT_TIMESTAMP;

etc, etc...

--
Jose' Soares
Bologna, Italy                     Jose@sferacarta.com



pgsql-general by date:

Previous
From: "omid omoomi"
Date:
Subject: Re: [GENERAL] CURRENT_DATE, CURRENT_TIME, CURRENT_TIMESTAMP
Next
From: Jeff MacDonald
Date:
Subject: Another Database Poll