Comparison of common ways to determine the size of the timestamp type of oracle accurate to the date

for example, if you want to query the data after a certain day, you need to make the time field of the timestamp type accurate to the date before judging the query. I don"t know what is the common way to deal with this situation.

now two solutions have been found:

  1. to_char (sysdate,"yyyy-mm-dd") format the date;
  2. trunc (sysdate) to intercept;

catch a glimpse of it while searching, it is said:

to_char formats the date as a string, and if the previous date field has an index, the index is invalidated.

trunc seems to intercept to the most recent date, partially adding "00:00:00" to the time.

which of the two are commonly used in actual use, are there any specific advantages and disadvantages, or are there other better ways.

Mar.16,2021

SELECT 1 FROM dual
WHERE SYSDATE > to_timestamp('2018-06-01', 'yyyy-mm-dd')
Menu