获得时间段之间每月的最后一天

create    FUNCTION   [ dbo ] . [ Fun_getbetwwenmonth ] ( @sdt   datetime , @edt   datetime )
 
RETURNS    @re   TABLE  (date  DATETIME )
 
AS
 
BEGIN
 
INSERT   INTO   @re      select
  
convert ( varchar ( 10 ), dateadd (dd, - 1 , convert ( varchar ( 8 ), dateadd (mm, number , @sdt ), 120 ) + ' 01 ' ), 120 )
from
  master..spt_values
where
  type
= ' p '   and   number > 0
and
  
dateadd (mm, number , @sdt ) <= dateadd (mm, 2 , @edt )
RETURN  
END

你可能感兴趣的:(时间)