SQL+C#实现获得当前月的第一天与最后一天
//C#代码 intyear=DateTime.Now.Year; intmonth=DateTime.Now.Month; DateTimefirstDayOfThisMonth=newDateTime(year,month,1); DateTimelastDayOfThisMonth=newDateTime(year,month,DateTime.DaysInMonth(year,month));
//SQL代码 DECLARE@NOWDATETIME DECLARE@FistDayOfThisMonthDATETIME DECLARE@LastDayOfThisMonthDATETIME SET@NOW=GETDATE() SET@FistDayOfThisMonth=@NOW-DAY(@NOW)+1 SET@LastDayOfThisMonth=DATEADD(MONTH,1,@NOW-DAY(@NOW)+1)-1 SELECT@FistDayOfThisMonth SELECT@LastDayOfThisMonth
以上就是本文的全部内容,希望对大家有所帮助,同时也希望多多支持毛票票!