Solved

comparing time using timestamptz

Posted on 2008-10-01
5
1,219 Views
Last Modified: 2012-05-05
hi, i have a string 00:33:11 and i need to compare it against a timestamptz field for specifying a constraint such that the 00:33:11 is before a timestamptz field in the database. how do i do that?

String a = "00:33:11";
e.g select a from tables where a < timestamptzfield
0
Comment
Question by:pothios
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 22

Expert Comment

by:earth man2
ID: 22618975
select a from tables where cast(a as time) <  cast( to_char( TIMESTAMPTZCOL,'HH24:MI:SS') as time);
0
 
LVL 2

Author Comment

by:pothios
ID: 22620775
a is not a field in a table. its just a string from my program where the user can select. the format of the string is 00:00:00
0
 
LVL 22

Accepted Solution

by:
earth man2 earned 500 total points
ID: 22622452
select * from  YOUR_TABLE
where
cast( :BIND_VARIABLE as time ) < 
cast( to_char( YOUR_TABLE.TIMESTAMPTZ_COLUMN,'HH24:MI:SS') as time );
0

Featured Post

Do you have a plan for Continuity?

It's inevitable. People leave organizations creating a gap in your service. That's where Percona comes in.

See how Pepper.com relies on Percona to:
-Manage their database
-Guarantee data safety and protection
-Provide database expertise that is available for any situation

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question