当月第一天 最后一天 C# SQL

C#

<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> int year = DateTime.Now.Year;
int month = DateTime.Now.Month;

DateTimefirstDayOfThisMonth
= new DateTime(year,month, 1 );
DateTimelastDayOfThisMonth
= new DateTime(year,month,DateTime.DaysInMonth(year,month));
SQL

<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--> DECLARE @NOW DATETIME
DECLARE @FistDayOfThisMonth DATETIME
DECLARE @LastDayOfThisMonth DATETIME

SET @NOW = GETDATE ()
SET @FistDayOfThisMonth = @NOW - DAY ( @NOW ) + 1
SET @LastDayOfThisMonth = DATEADD ( MONTH , 1 , @NOW - DAY ( @NOW ) + 1 ) - 1

SELECT @FistDayOfThisMonth
SELECT @LastDayOfThisMonth

你可能感兴趣的:(sql,C++,c,C#)