SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Useful Dates: The Many Uses of Date Tables


Useful Dates: The Many Uses of Date Tables

Author
Message
CheeseMan316
CheeseMan316
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 71
Bob Hovious (12/17/2008)
Could you give us a real world example or two using other dimensions besides day?


I have worked with large data warehouse applications that do a lot of data aggregation. The ability to roll data up into non-day increments (hours, months, quarters and years) is useful in those applications. It allows you to store the aggregated data referenced by a single time coordinate. I'm not suggesting that a set of data be linked to ALL dimensions. So you wouldn't link a record to the year 2008, Quarter 1, Month 10 and day 10 if it was 10-OCT-2008. But if you do periodical aggregation as the need for granularity decreases as data ages, the ability to use a single value to represent that can be useful.
CheeseMan316
CheeseMan316
SSC Rookie
SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)SSC Rookie (36 reputation)

Group: General Forum Members
Points: 36 Visits: 71
TheSQLGuru (12/17/2008)
It is customary and useful to have your int date keys be formatted CCYYMMDD, at least in the classical date dimension scenario. Identities are really not helpful here.


What format would you propose for the quarterly and hourly values?
TheSQLGuru
TheSQLGuru
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12867 Visits: 8565
I had zoned out when I posted that this date table is more granular than day. Hehe

Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
Michael Valentine Jones
Michael Valentine Jones
SSCertifiable
SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)SSCertifiable (5.9K reputation)

Group: General Forum Members
Points: 5942 Visits: 11771
Here is another approach on the link below. Function F_TABLE_DATE is a multistatement table-valued function that returns a table containing a variety of attributes of all dates from @FIRST_DATE through @LAST_DATE. It was intended mainly to be able to load a date table, but is can also be used directly in a statement for those occasions when you want to go outside your standard ranges.

This function has about 65 columns representing just about every date attribute I have ever had any need for. It does not include any Fiscal period attributes, since that is something that is usually specific to a particular organization.


Date Table Function F_TABLE_DATE
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=61519
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search