From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Brandon Metcalf <brandon(at)geronimoalloys(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: timestamp no fractional seconds |
Date: | 2009-06-02 16:40:10 |
Message-ID: | 162867790906020940g7b21fad9u1b8d2bf23e01cc81@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
use timestamp(0)
timestamp[0] means array of timestamps
regards
Pavel Stehule
2009/6/2 Brandon Metcalf <brandon(at)geronimoalloys(dot)com>:
> I need to create a table with two columns of type timestamp but I
> don't want to store any fractional part of the seconds field. So,
> I created a table with:
>
> CREATE TABLE timeclock (
> timeclock_id SERIAL,
> employee_id INTEGER,
> clockin TIMESTAMP[0] NOT NULL,
> clockout TIMESTAMP[0] DEFAULT NULL,
>
> PRIMARY KEY (timeclock_id),
>
> FOREIGN KEY (employee_id)
> REFERENCES employee
> ON DELETE RESTRICT
> ON UPDATE CASCADE
> );
>
> But now I can no longer insert a timestamp as I normally would:
>
> gms=# insert into timeclock (employee_id,clockin,clockout) values(3169,now(),null);
> ERROR: column "clockin" is of type timestamp without time zone[] but expression is of type timestamp with time zone
> LINE 1: insert into timeclock (employee_id,clockin,clockout) values(...
> ^
> HINT: You will need to rewrite or cast the expression.
>
> If I cast it, I get something really strange:
>
> gms=# insert into timeclock (employee_id,clockin,clockout) values(3169,now()::timestamp,null);
> ERROR: column "clockin" is of type timestamp without time zone[] but expression is of type timestamp without time zone
> LINE 1: insert into timeclock (employee_id,clockin,clockout) values(...
> ^
> HINT: You will need to rewrite or cast the expression.
>
> Am I creating the table correctly? If so, how do I insert or update
> rows?
>
> Thanks.
>
>
> --
> Brandon
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2009-06-02 16:42:55 | Re: timestamp no fractional seconds |
Previous Message | Brandon Metcalf | 2009-06-02 16:40:08 | Re: timestamp no fractional seconds |