This below link is an example showing a scenario which can be used to create a YTD transformation table in Microsoft SQL Server. This can be used for YTD, MTD, and QTD transformations which require table based transformations. The logic here is assuming there is already a lookup table with unique day data in it. This can be tweaked as needed and should only be used as a base if help is needed building out transformation tables within a SQL Server warehouse.

http://www.dietz-solutions.com/2014/05/creating-ytd-transformation-tables.html