Solved

comparing time using timestamptz

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

896 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now