For a projet I had to find the previous month - in format ‘mm.yyyy’.
Here is the code:
– =============================================
– Author: Praveen
– Create date: 22-02-2007
– Description: To find the previous month in format ‘month.year’
– =============================================
CREATE FUNCTION dbo.gf_PreviousMonth (@d char(7))
RETURNS char(7)
AS
BEGIN
DECLARE @dt AS datetime
SET @dt = [...]