• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1301
  • Last Modified:

comparing time using timestamptz

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
pothios
Asked:
pothios
  • 2
1 Solution
 
earth man2Commented:
select a from tables where cast(a as time) <  cast( to_char( TIMESTAMPTZCOL,'HH24:MI:SS') as time);
0
 
pothiosAuthor Commented:
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
 
earth man2Commented:
select * from  YOUR_TABLE
where
cast( :BIND_VARIABLE as time ) < 
cast( to_char( YOUR_TABLE.TIMESTAMPTZ_COLUMN,'HH24:MI:SS') as time );
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now