Summary:
How to query related data by using the time field as a condition in Oracle.
universal:
The to_char() function that comes with oracle is used
1. Less than a certain time (accurate to hours, minutes and seconds):
SELECT
*
FROM
OP_BS_CC
WHERE
TRANS_TIME < TO_DATE (
'2018-04-23 10:39:00',
'yyyy-mm-dd hh24:mi:ss'
);
1.1. Then if the event is greater than a certain event, you only need to change the less-than sign to a greater-than sign.
1.2. If the pointer is accurate to the year, month and day, then the content of to_char() becomes ('2018-04-23','yyyy-mm-dd')
2. During a certain period of time
In this case, the between...and keyword is used more.
SELECT
*
FROM
OP_BS_CC
WHERE
TRANS_TIME
BETWEEN
"TO_DATE"(
'2018-04-23 10:38:00',
'yyyy-mm-dd hh24:mi:ss')
AND
"TO_DATE" (
'2018-04-23 10:40:00',
'yyyy-mm-dd hh24:mi:ss'
);
But of course you can also use the > and < signs.
SELECT
*
FROM
OP_BS_CC
WHERE
TRANS_TIME > "TO_DATE"
('2018-04-23 10:38:00',
'yyyy-mm-dd hh24:mi:ss')
AND
TRANS_TIME < TO_DATE (
'2018-04-23 10:40:00',
'yyyy-mm-dd hh24:mi:ss'
);