--To get the first day of month and day name by any date Declare @pInputDate Datetime set @pInputDate=getdate()- 40 set @pInputDate= CAST(CAST(YEAR(@pInputDate) AS VARCHAR(4)) + '/' + CAST(MONTH(@pInputDate) AS VARCHAR(2)) + '/01' AS DATETIME) --Will give First date of the month
--Will give day of the date select @pInputDate AS First_Day_of_mth, datename(dw,@pInputDate) AS Day_Name
-- to Get last date of a month Declare @Enddate Datetime set @Enddate = getdate() SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@Enddate)+1,0)) as lastday
how to write a query for getting the first day of the month? exeample : oct - 1 - 2007 means monday i want to get like this.
SELECT MONTH(getdate()) as month1, DAY(0) as date, YEAR(getdate()) as year1
|
No responses found. Be the first to respond and make money from revenue sharing program.
|