Weeks Calculation for Adventureworks Time Dimension

The following Named Calculated filed returns Week Start Date & End Date.

'Week ' + Convert(Char(2), WeekNumberOfYear) + '(' +
Convert(Char(10),(FullDateAlternateKey - (DATEPART(dw,FullDateAlternateKey)-1)),101) + ' - ' +
Convert(Char(10),(FullDateAlternateKey - (DATEPART(dw,FullDateAlternateKey) - 1) + 6),101) + ')'

Examples:
-- for Date '2008-01-01', Returns Week 1(01/01/2008 - 01/07/2008)
-- for Date '2008-09-08', Returns Week 37(09/07/2008 - 09/13/2008)


ExcelSheet Formulas for Week Calculation:

Date Cell(A2): 09/08/2008

Week Start Date Cell(K2): =DATE(YEAR(A2), MONTH(A2), DAY(A2) - (WEEKDAY(A2) - 1))

-- Returns 09/07/2008

Week End Date Cell(L2): =DATE(YEAR(A2), MONTH(A2), DAY(A2) - (WEEKDAY(A2) - 1) + 6)

--Returns 09/13/2008

Start & End Date: =CONCATENATE(YEAR(A2), " - Week ", WEEKNUM(A2), " (", TEXT(K2, "mm/dd/yyyy"), " - ", TEXT(L2, "mm/dd/yyyy"), ")")

-- Returns Week 37(09/07/2008 - 09/13/2008)

Quarter Calcualtion:

=TEXT(A2,"yyyy") & " - " &"Q"&INT(((MONTH(A2))-1)/3)+1

-- Returns 2008 - Q3

Comments

Popular posts from this blog

Windows Azure Package Build Error: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

Resource ID : 1. The request limit for the database is 180 and has been reached.

Update Excel Sheet using C#, Where Excel not Installed on Server