I hace sql query through this i want to calculate the records after 05:00:00 PM and before
05:00:00 PM.Here i smy query but through this i am getting wrong results please any one check this if any logical error in this
Select trunc(gross_weight_date) date1,
count(*) before5
from wbg.WBG_01_01
where to_char(gross_weight_date,'HH:MI:SS PM')>'05:00:00 PM'
and item_cod = 16
and trunc(gross_weight_date)='05-JAN-2012'
group by trunc(gross_weight_date)
order by date1
Any help may apprecaited
You are using
charsto compare dates. That won’t work properly.Since you only want to compare after 05 PM, here’s an easier solution:
It passes the value of the date to a char (‘171212’) and then to a number (171212) and compares it to 150000.