How can I select the first day of a month in SQL?
SELECT DATEADD(month, DATEDIFF(month, 0, @mydate), 0) AS StartOfMonth
In addition to all the above answer, a way based on a function introduced in sql 2012
SELECT DATEFROMPARTS(YEAR(@mydate),MONTH(@mydate),1)
Starting with SQL Server 2012:
SELECT DATEADD(DAY,1,EOMONTH(@mydate,-1))