Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a column which is of "DATE" type and I want to run a query on it comparing it with sysdate.

But I am getting following error, Can someone please let me know what I am missing here?

SQL> select distinct file_name as r 
     from table_1 
     where view_day >= TO_DATE(SYSDATE-10, 'YYYY/MM/DD');

ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.3k views
Welcome To Ask or Share your Answers For Others

1 Answer

You shouldn't use to_date on a date, To_date is for casting a varchar to date, not a date.
If you do use the function to_date on a date, then oracle will refer to it as a string according to nls_date_format which may vary in different environments.
As @jonearles said, if you want to remove the time in sysdate then use TRUNC


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...