Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building a Time Dimension Copyright © 2001 by Michael A. Mina.

Similar presentations


Presentation on theme: "Building a Time Dimension Copyright © 2001 by Michael A. Mina."— Presentation transcript:

1 Building a Time Dimension Copyright © 2001 by Michael A. Mina

2 2 Create (manually or otherwise) one table listing the digits 0 through 9.

3 Copyright © 2001 by Michael A. Mina3 SELECT 1000*A.Digit+100*B.Digit+10*C.Digit+D.Digit AS DateKey, DateAdd("d",1000*A.Digit+100*B.Digit+10*C.Digit+D.Digit,#01/01/1 990#) AS DateValue INTO DateValues FROM Digits AS A, Digits AS B, Digits AS C, Digits AS D ORDER BY 1; Write a cross join query to create a Cartesian product of the table with itself four times. Our SELECT statement will use the Cartesian product to create the integers 0 through 10,000. The DateAdd function will add these integers to a starting date (in this case, 1/1/1990). Different databases may use a different function to add integers to dates.

4 Copyright © 2001 by Michael A. Mina4

5 5 SELECT DateKey, DateValue, Day(DateValue) AS Day, Month(DateValue) AS Month, Int((Month(DateValue)+2)/3) AS Quarter, Year(DateValue) AS Year INTO TimeDimension FROM DateValues; Create a Time dimension table using the previous table. Use the row functions provided by your database to add the information you need. Remember to create a primary key on the Time dimension table.

6 Copyright © 2001 by Michael A. Mina6


Download ppt "Building a Time Dimension Copyright © 2001 by Michael A. Mina."

Similar presentations


Ads by Google