In Oracle, we used whereto_char (t. t_created_tm,
Use where to_char (t. t_created_tm,
Oracle to get today's data, previously used to where to_char (t. t_created_tm, 'yyyy-MM-DD ') = to_char (SYSDATE, 'yyyy-MM-DD ');
This method is inefficient, and even if t. t_created_tm is indexed, the index cannot be used during query because it is compared after function encapsulation.
Here we will introduce how to use TRUNC (SYSDATE) = today to compare and filter data to get the results of today's data.
Select trunc (SYSDATE) from dual;
-- TRUNC (SYSDATE)
The following method is better.
SELECT * FROM TBL_STEP t where T.T _ CREATE_TM> = TRUNC (SYSDATE );
If the current year's data is retrieved
SELECT * FROM TBL_STEP t where T.T _ CREATE_TM> = TRUNC (SYSDATE, 'yyyy ');
Data for the current month
SELECT * FROM TBL_STEP t where T.T _ CREATE_TM> = TRUNC (SYSDATE, 'mm') AND T.T _ CREATE_TM <= LAST_DAY (SYSDATE)