Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DECLARE @start_dt SMALLDATETIME
IF MONTH(GETDATE()) = 1
BEGIN
SELECT
@start_dt = '12/1/' + CONVERT(CHAR(4), YEAR(GETDATE()) - 1)
END
ELSE
BEGIN
SELECT
@start_dt = CONVERT(CHAR(2), MONTH(GETDATE()) - 1) + '/1/' + CONVERT(CHAR(4), YEAR(GETDATE()))
END
SELECT DATEADD(MONTH,-1,DATEADD(DAY,DATEDIFF(DAY,0,GETDATE(),0))
CAST(CAST((CASE MONTH('Aug 12 2004') WHEN 1 THEN 12 ELSE MONTH('AUG 12 2004')-1 END) AS VARCHAR(2)) + '/01/' + CAST((CASE MONTH('Aug 12 2004') WHEN 1 THEN YEAR('Aug 12 2004') - 1 ELSE YEAR('Aug 12 2004') END) AS VARCHAR(4)) AS DATETIME)
select dateadd(month,-1,(dateadd(day, -(datepart(day,getdate()-1)), (dateadd(day,datediff(day,0,getdate()),0)))))
SELECT Convert(datetime,Convert(int,Convert(float,DateAdd(m,-1,GetDate()-Day(GetDate())+1))))
-- and even shorter:
SELECT DateAdd(m,-1,Convert(varchar(8),GetDate(),112))-Day(GetDate())+1