Re: timestamp no fractional seconds

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: timestamp no fractional seconds
Дата
Msg-id 162867790906020942k1ebb4727ob96e997aa2c3904a@mail.gmail.com
обсуждение исходный текст
Ответ на Re: timestamp no fractional seconds  (Brandon Metcalf <brandon@geronimoalloys.com>)
Список pgsql-general
2009/6/2 Brandon Metcalf <brandon@geronimoalloys.com>:
> b == brandon@geronimoalloys.com writes:
>
>  b> I need to create a table with two columns of type timestamp but I
>  b> don't want to store any fractional part of the seconds field.  So,
>  b> I created a table with:
>
>  b>   CREATE TABLE timeclock (
>  b>       timeclock_id  SERIAL,
>  b>       employee_id   INTEGER,
>  b>       clockin       TIMESTAMP[0]    NOT NULL,
>  b>       clockout      TIMESTAMP[0]    DEFAULT NULL,
>
>  b>       PRIMARY KEY (timeclock_id),
>
>  b>       FOREIGN KEY (employee_id)
>  b>           REFERENCES employee
>  b>           ON DELETE RESTRICT
>  b>           ON UPDATE CASCADE
>  b>   );
>
>  ...
>
>  b> Am I creating the table correctly?  If so, how do I insert or update
>  b> rows?
>
>
> I suppose my question really boils down to how do I cast the timestamp
> with no fractional seconds part?  For example, if I have a table where
> I haven't put a limit on the fractional seconds part, how would I
> select the timestamp without fractional seconds?
>
>
>  gms=> select clockin from timeclock;
>
>            clockin
>  ----------------------------
>   2009-06-02 11:34:21.314392
>  (1 row)
>
>  gms=> select clockin::timestamp without time zone[0] from timeclock;
>  ERROR:  cannot cast type timestamp without time zone to timestamp without time zone[]
>  LINE 1: select clockin::timestamp without time zone[0] from timecloc...
>                          ^
>  gms=> select clockin::timestamp[0] from timeclock;
>  ERROR:  cannot cast type timestamp without time zone to timestamp without time zone[]
>  LINE 1: select clockin::timestamp[0] from timeclock;
>
>
> --
> Brandon
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


postgres=# select now()::timestamp(0);
         now
---------------------
 2009-06-02 18:42:41
(1 row)

Time: 173,165 ms
postgres=#


regards
Pavel

В списке pgsql-general по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: timestamp no fractional seconds
Следующее
От: Brandon Metcalf
Дата:
Сообщение: Re: timestamp no fractional seconds