find month days

假装没事ソ 提交于 2019-12-11 20:43:16

问题


I need to find how many days have in this month which we can find with today's date

select to_number(to_date('01.02.2011')-to_date('01.01.2011')) from dual; 

not this query Have any other queries?


回答1:


You can do it with a trunc(<date>, 'mm') (which returns the first day of the month) and an add_months(<date>,1) which add one month to a particular day. So, in order to find out how many days the month has in which we currently are (i.e. sysdate), you could go with something like:

select  
  add_months(trunc(sysdate, 'mm'),1) - trunc(sysdate, 'mm') 
from 
  dual;



回答2:


select extract(day from last_day(sysdate)) from dual

?




回答3:


select DateDiff(Day,GETDATE(),DateAdd(month,1,GETDATE()))


来源:https://stackoverflow.com/questions/4712863/find-month-days

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