SELECT loginname,endtime FROM dailysessionpre_table where days='2020-11-16' and length(ACCTSESSIONTIME) > 30 and endtimebetween to_date('15/11/2020 23:45:00', 'dd/MM/yyyy hh24:mi:ss') and to_date('16/11/2020 00:15:00', 'dd/MM/yyyy hh24:mi:ss'); SELECT loginname,endtime FROM dailysessionpre_table where days='2020-11-16' and length(ACCTSESSIONTIME) > 30 and endtime 11-20 03:59