Home » SQL & PL/SQL » SQL & PL/SQL » How to check records between AM && PM in a single day
How to check records between AM && PM in a single day [message #193336] Fri, 15 September 2006 14:22 Go to next message
cgk1983
Messages: 28
Registered: December 2005
Junior Member
I want to filter records from a table having DATE datatype column like this:-

COL1 COL2
------ -----
9/15/2006 1:04:51 PM This is sample test1
9/15/2006 2:04:51 PM This is sample test2
9/15/2006 3:04:51 PM This is sample test3
9/15/2006 4:04:51 PM This is sample test4
9/15/2006 5:04:51 PM This is sample test5
9/15/2006 6:04:51 PM This is sample test6
9/15/2006 11:04:51 AM This is sample test7
9/15/2006 10:04:51 AM This is sample tes8
9/15/2006 9:04:51 AM This is sample tes9

I want to retrieve records present only after 3PM onwards
i tried like this

select col1,col2 from test where to_char(col1,'HH12')>='03'

but i am getting all values greater than 3

Bcoz it is comparing with string 03 i am getting these records also 11:04:51 AM ,10:04:51 AM ,9:04:51 AM

How to check records between AM && PM in a single day
Re: How to check records between AM && PM in a single day [message #193337 is a reply to message #193336] Fri, 15 September 2006 14:47 Go to previous messageGo to next message
kimant
Messages: 201
Registered: August 2006
Location: Denmark
Senior Member
One option is

where trunc(col1)+15/24 < col1

I do not understand what You mean by between AM & PM, but I am also always using 24H.

Br
Kim
Re: How to check records between AM && PM in a single day [message #193340 is a reply to message #193337] Fri, 15 September 2006 15:14 Go to previous messageGo to next message
cgk1983
Messages: 28
Registered: December 2005
Junior Member
Thank You
Re: How to check records between AM && PM in a single day [message #193343 is a reply to message #193336] Fri, 15 September 2006 15:38 Go to previous message
joy_division
Messages: 4642
Registered: February 2005
Location: East Coast USA
Senior Member
where to_char(col1,'HH24')>='15'

midnight through noon was showing up in your way because you were only using a 12 hour clock.
Previous Topic: Trigger Problem
Next Topic: Post data in AP interface table
Goto Forum:
  


Current Time: Wed Dec 07 18:36:32 CST 2016

Total time taken to generate the page: 0.19818 seconds