dbTalk Databases Forums  

Wildcard for date in SELECT from type TIMESTAMP

comp.databases.postgresql comp.databases.postgresql


Discuss Wildcard for date in SELECT from type TIMESTAMP in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Julia Jacobson
 
Posts: n/a

Default Wildcard for date in SELECT from type TIMESTAMP - 08-21-2010 , 12:32 PM






Dear PostgreSQL users,
How can I select all entries having a time of earlier than for example
11:00:00 from a column with data type TIMESTAMP, no matter what the date is?
There has probably already been someone with this problem, but I really
wasn't able to find anything here or in the web.
Thanks in advance,
Julia

Reply With Quote
  #2  
Old   
Thomas Kellerer
 
Posts: n/a

Default Re: Wildcard for date in SELECT from type TIMESTAMP - 08-21-2010 , 01:07 PM






Julia Jacobson wrote on 21.08.2010 19:32:
Quote:
Dear PostgreSQL users,
How can I select all entries having a time of earlier than for example
11:00:00 from a column with data type TIMESTAMP, no matter what the date
is?
There has probably already been someone with this problem, but I really
wasn't able to find anything here or in the web.
Thanks in advance,
Julia
this should work:

SELECT *
FROM the_table_with_no_name
WHERE cast(the_timestamp_column as time) <= TIME '11:00:00'

Thomas

Reply With Quote
  #3  
Old   
Julia Jacobson
 
Posts: n/a

Default Re: Wildcard for date in SELECT from type TIMESTAMP - 08-21-2010 , 02:20 PM



Yes, it does. Thanks a lot.

Quote:
Julia Jacobson wrote on 21.08.2010 19:32:
Dear PostgreSQL users,
How can I select all entries having a time of earlier than for example
11:00:00 from a column with data type TIMESTAMP, no matter what the date
is?
There has probably already been someone with this problem, but I really
wasn't able to find anything here or in the web.
Thanks in advance,
Julia

this should work:

SELECT *
FROM the_table_with_no_name
WHERE cast(the_timestamp_column as time) <= TIME '11:00:00'

Thomas

Reply With Quote
  #4  
Old   
Andreas Kretschmer
 
Posts: n/a

Default Re: Wildcard for date in SELECT from type TIMESTAMP - 08-23-2010 , 01:02 AM



Julia Jacobson <julia.jacobson (AT) arcor (DOT) de> wrote:
Quote:
Yes, it does. Thanks a lot.


this should work:

SELECT *
FROM the_table_with_no_name
WHERE cast(the_timestamp_column as time) <= TIME '11:00:00'
Just for info:

If you have a large table and you want to improve the speed, you can
create an functional index:

create index a_index on a_table((a_column::time));


Andreas
--
Andreas Kretschmer
Linux - weil ich es mir wert bin!
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.