Mohit Khandelwal
Mohit Khandelwal

Reputation: 45

How to filter data by pm(time) in oracle?

I have a table in which I have inserted trainno and its time of arrival now I need to display trains which arrived on PM. I have tried this select trainno,to_char(timeofarrival,'HH:MI:SS A.M.')"toa" from train where to_char(timeofarrival,'HH:MI:SS A.M.')='P.M.'; enter image description here

Upvotes: 0

Views: 46

Answers (1)

Justin Cave
Justin Cave

Reputation: 231781

Sincce timeOfArrival is a date

WHERE to_number( to_char( timeOfArrival, 'HH24' )) >= 12

will give you the rows where the time component is after noon.

Upvotes: 2

Related Questions