find month days

2019-08-18 01:50发布

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?

标签: sql oracle10g
3条回答
手持菜刀,她持情操
2楼-- · 2019-08-18 02:24
select extract(day from last_day(sysdate)) from dual

?

查看更多
狗以群分
3楼-- · 2019-08-18 02:27
select DateDiff(Day,GETDATE(),DateAdd(month,1,GETDATE()))
查看更多
叼着烟拽天下
4楼-- · 2019-08-18 02:37

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;
查看更多
登录 后发表回答