A co-worker asked me about a different thread where I'd posted an advanced solution to a common problem, and I was explaining/demoing a feature... I found an unexpected result!

The code in question is:
Code:
--  ptp  20140401  Demo running totals

--  Setup the scenario

DECLARE @d1         DATETIME2
,  @d2              DATETIME2
,  @d3              DATETIME2

DECLARE @t          TABLE
   (asof            DATE            NOT NULL
,  bucks            DECIMAL(10, 2)  NOT NULL
   )

INSERT INTO @t
   SELECT DateAdd(day, v.number, '2000-01-01'), v.number
      FROM master.dbo.spt_values AS v
	  WHERE  'P' = v.type

--  Here's where the work happens!

SET @d1 = GetDate()

SELECT asof
,  bucks
,  Sum(bucks) OVER (
      PARTITION BY Convert(CHAR(7), asof, 121) 
	  ORDER BY asof 
	  RANGE UNBOUNDED PRECEDING) AS mtd
,  Sum(bucks) OVER (
	  PARTITION BY Convert(CHAR(4), asof, 121) 
	  ORDER BY asof 
	  RANGE UNBOUNDED PRECEDING) AS ytd
   FROM @t
   ORDER BY asof

SELECT @d2 = GetDate()

SELECT asof
,  bucks
,  Sum(bucks) OVER (
      PARTITION BY DateAdd(month, DateDiff(month, 0, asof), 0)
	  ORDER BY asof 
	  RANGE UNBOUNDED PRECEDING) AS mtd
,  Sum(bucks) OVER (
	  PARTITION BY DateAdd(year, DateDiff(year, 0, asof), 0)
	  ORDER BY asof 
	  RANGE UNBOUNDED PRECEDING) AS ytd
   FROM @t
   ORDER BY asof

SELECT @d3 = GetDate()

SELECT DateDiff(ms, @d1, @d2) AS 'Convert'
,  DateDiff(ms, @d2, @d3) AS 'DateAdd'
The interesting part is the final result set (just two numbers). Please run and post on a few machines and respond with your results (the numbers from the final result set and a brief description of your SQL Server hardware/software configuration).

Running on a client laptop (8 GB, Intel i5 @ 2.40 GHz, Windows 7 x64, SQL 2012 Dev x64) the values were:

Code:
Convert	DateAdd
123	160
-PatP