T-SQL 函数:计算未来 500 天所在月份的天数
CREATE FUNCTION dbo.days_in_month (@date DATE) RETURNS INT AS BEGIN DECLARE @days_in_month INT; DECLARE @next_month DATE; SET @next_month = DATEADD(month, 1, @date); SET @days_in_month = DATEDIFF(day, @date, @next_month); RETURN @days_in_month; END;
SELECT dbo.days_in_month(DATEADD(day, 500, GETDATE())) AS days_in_month_after_500_days;
原文地址: https://www.cveoy.top/t/topic/mAoO 著作权归作者所有。请勿转载和采集!