int
year
=
DateTime.Now.Year;
int month = DateTime.Now.Month;
DateTime firstDayOfThisMonth = new DateTime(year, month, 1 );
DateTime lastDayOfThisMonth = new DateTime(year, month, DateTime.DaysInMonth(year, month));
SQL
int month = DateTime.Now.Month;
DateTime firstDayOfThisMonth = new DateTime(year, month, 1 );
DateTime lastDayOfThisMonth = new DateTime(year, month, DateTime.DaysInMonth(year, month));
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
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