Solved

comparing time using timestamptz

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to rsync without password on Ubuntu 12.04.4 LTS 8 802
postgresql limit data for month year week 5 483
OS X postgresql logging 1 288
PostgreSQL 9.2 - SQL import error 1 153
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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