How to subtract years from sysdate

泄露秘密 提交于 2021-02-06 15:01:52

问题


What would be the expression to check if someone's 20 years or over without hard-coding the date?

In the SQL

 SELECT student_fname 
 FROM students
 WHERE dob<'05-MAR-1995';

I was thinking about using SYSDATE but then I don't know the syntax to subtract 20 years.


回答1:


WHERE dob < add_months( trunc(sysdate), -12*20 );

would work assuming that you want to ignore the time component of sysdate.



来源:https://stackoverflow.com/questions/28888848/how-to-subtract-years-from-sysdate

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!