Date Dimension: use date in YYYYMMDD format if your granular level is a single date

It still surprises me how many people set up the DateDimID as Identity(1, 1).

If you use YYYYMMDD format, then on some reports, you can even display the date without navigating to the Date dimension to show label.  In the same deal, you can use YYYYMM for a monthly date dimension, and YYYY for a yearly date dimension.

[Update 2012-10-16]

I now realize that what I said before was a clunky way to build dimension (hey I didn't say I was the expert.  :D)  And using only that argument going up against Kimball's teaching earned me a black eye.  However, here is the second argument I heard:

Using yyyyMMdd format improves ETL performance before you no longer need to join to the Date Dim staging table to get the Dim key, you just need to do YEAR(@date) *10000 + MONTH(@date) * 100 + DAY(@date)

Now that's a much better argument.  :)

This article is part of the GWB Archives. Original Author: Kevin Shyr

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.