The first day of each month is always 1. However if you interested to find the First and Last Date of each month using a Sql Query, here it is:
-- Return First and Last Date of a Month
DECLARE @Month smallint
SET @Month = 1
SELECT DAY(DATEADD(Month, DATEDIFF(Month, -1, getdate()) - 2, -1) + 1) as FirstDayofMonth,
DAY(DATEADD(Month, DATEDIFF(Month,0,getdate())+@Month, -1)) as LastDayOfMonth
If you wish to find out the Lastday of the previous month, just set @Month to 0.
No comments :
Post a Comment