given a timestamp data, e.g. 2001-08-18 06:01:23+08
How can I check that is it lie between 00:00:00 and 08:00:00 and ignore the
date?

--
content-type:kiss/hug

Search Discussions

  • Justin Clift at Aug 20, 2001 at 7:10 pm
    Hi,

    You could do something along the lines of :

    SELECT foo, bar FROM baz WHERE date_part('hour', foo) > 0 AND
    date_part('hour', foo) < 8;

    Simple, but effective. Only works for whole hours like in your example
    though.

    :-)

    Regards and best wishes,

    Justin Clift


    Cefull Lo wrote:
    given a timestamp data, e.g. 2001-08-18 06:01:23+08
    How can I check that is it lie between 00:00:00 and 08:00:00 and ignore the
    date?

    --
    content-type:kiss/hug

    ---------------------------(end of broadcast)---------------------------
    TIP 5: Have you checked our extensive FAQ?

    http://www.postgresql.org/users-lounge/docs/faq.html
    --
    "My grandfather once told me that there are two kinds of people: those
    who work and those who take the credit. He told me to try to be in the
    first group; there was less competition there."
    - Indira Gandhi
  • Jason Earl at Aug 21, 2001 at 6:52 pm
    On my box:

    processdata=# select version();
    version

    ---------------------------------------------------------------
    PostgreSQL 7.1.3 on i686-pc-linux-gnu, compiled by
    GCC 2.95.4
    (1 row)

    You can do something like this:

    SELECT dt, dt::time FROM prod_journal WHERE dt::time
    BETWEEN '00:00:00' AND '08:30:00';

    dt in this case is a timestamp field, and the results
    are what you would expect.

    Take care,
    Jason


    --- Justin Clift wrote:
    Hi,

    You could do something along the lines of :

    SELECT foo, bar FROM baz WHERE date_part('hour',
    foo) > 0 AND
    date_part('hour', foo) < 8;

    Simple, but effective. Only works for whole hours
    like in your example
    though.

    :-)

    Regards and best wishes,

    Justin Clift


    Cefull Lo wrote:
    given a timestamp data, e.g. 2001-08-18
    06:01:23+08
    How can I check that is it lie between 00:00:00
    and 08:00:00 and ignore the
    date?

    --
    content-type:kiss/hug

    ---------------------------(end of
    broadcast)---------------------------
    TIP 5: Have you checked our extensive FAQ?
    http://www.postgresql.org/users-lounge/docs/faq.html

    --
    "My grandfather once told me that there are two
    kinds of people: those
    who work and those who take the credit. He told me
    to try to be in the
    first group; there was less competition there."
    - Indira Gandhi

    ---------------------------(end of
    broadcast)---------------------------
    TIP 3: if posting/reading through Usenet, please
    send an appropriate
    subscribe-nomail command to majordomo@postgresql.org
    so that your
    message can get through to the mailing list cleanly

    __________________________________________________
    Do You Yahoo!?
    Make international calls for as low as $.04/minute with Yahoo! Messenger
    http://phonecard.yahoo.com/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-general @
categoriespostgresql
postedAug 20, '01 at 2:45p
activeAug 21, '01 at 6:52p
posts3
users3
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase