Hello everyone,
I want to create a chart in vb.net that shows the cost of my expenses for the last 12 months for each month how much I have spent to be shown.
I want that it goes with my pc time, so if we have no December I want the chart to automatically show me the cost for 12 months.
SELECT Sum(Price) As Total,
DATEPART(MM, Date) As [year],
Sum (CONVERT(INT, CONVERT(VARCHAR(MAX),quantity))) as Lesh
FROM dbo.Expenses
WHERE date >=DATEADD(month,-12,DATEADD(day,DATEDIFF(day,0,GETDATE()),0)) AND date <=DATEADD(day,DATEDIFF(day,0,GETDATE()),0)
GROUP BY DATEPART(MM, Date)
Thank you very kindly,
Elvis