Solved

comparing time using timestamptz

Posted on 2008-10-01
5
1,208 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Netezza Function 9 4,472
postgresql looking for max of each group by name 3 246
Database config on Codeigniter 9 322
Can SQL do Pythagoras? 8 68
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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