Don McMunn's FREEWARE Date Dimension Tool Kit Version 2.14 Released: 17-Aug-2007
| Why? | What? | Download | Date Table | Comments | Home | My Resume | Free DPTK |
Free ETL MD |
|
|
||||||||
|
Please visit these handy sites as well...
Steve Hoberman's Data Modeling Zone Barry Ralston's Microsoft BI blog | ||||||||
| Visit the World Clock | ||||||||
| The Calendar Zone | ||||||||
| Kimball Group - Microsoft Data Warehouse Toolkit Tools | ||||||||
|
COMMENTS: "Excellent work!" "Thanks for sharing these queries with the license." "This site was very helpful." "I am on an Oracle 9.2 database and the ready-made .csv file saved me from having to write a PL/SQL program built around SYSDATE to get all the DATE columns. With over 60 columns there is every permutation of DATE that you could ever want. The whole process including finding this site took less than a day!" "I'm getting into the Kimball stuff. You just saved me hours of work. Brilliant!" "Thanks for the freeware. It really was a big help. You saved me many hours and days of manual calculations." "Thanks for the tools." |
||||||||
|
Every data warehouse, reporting or business intelligence environment can benefit from a handy, dandy date lookup or reference table. AKA "a date dimension". This is grunt work at best, and frankly, I'm tired of doing it over and over at each new account, so...download and enjoy...I will! What's in the box? The Date Dimension Tool Kit contains the fundamental, pre-calculated Gregorian Calendar Date Dimension table source data for the range of January 1, 1900 to December 31, 2499. There are also source scripts for those who STILL want to D-I-Y, data models (both denormalized and 3-N-F), a US holiday calendar, an Excel spreadsheet to generate either a Gregorian or 4-4-5 fiscal calendar, and a some simple instruction to kick-start the process. What're you waiting for? ...read on, download and go do something more productive for your team, customer and yourself. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Custom Search
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Errata: 13-Sep-2007==> The day of the week was reported to be off by one (Saturday January 1, 2000 showing as Sunday) in the Excel Calendar building spreadsheet. - Chris 14-Sep-2007==> I was unable to confirm the issue reported by "Chris" above. If anyone else experiences an issue with day of the week being off by one, please let me hear from you. Otherwise, I will consider it closed. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LEGAL STUFF:DISCLAIMER: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. LICENSE:
Date Dimension Kit by Don McMunn is licensed under a Creative Commons Attribution 3.0 License. Based on a work at www.ipcdesigns.com. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From the base data elements in the files below, a large portion of additional attributes may be calculated via clever SQL or brute force such as begin/end parent time periods/keys, previous time periods; future time periods, etc... These date-related attributes will make reporting and complex, date dependent ad-hoc queries easier to develop, maintain and extend. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The process of creating the essential date-based attributes of all database applications and reporting systems of record is a snap with this toolkit. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
INSTRUCTIONAL GUIDE: NOTE: You must have sufficient database permissions to create tables, indexes, select, update, delete and insert data to perform all these steps. You will also need to be able to uncompress a Zip file to access the source data files.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Useful SQL scripts will be added to this site by me (and hopefully by the community, too!) to provide additional date related attributes. So, make sure to check back from time to time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
10-Jan-2008 - new script to populate the fiscal columns in dim_day for US Federal calendar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DownloadsNOTE: Each of the data source files below is compressed as a .ZIP file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
SQL Table Definition for days: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(Click here for the full dim_day table creation script)
For SQL Server:
CREATE TABLE dim_day
(
date_key int NOT NULL
, date_type varchar (20) NULL CONSTRAINT DF_dim_day_date_type Default('NORMAL')
, full_date datetime NULL
, day_num_of_week int NULL
, day_num_of_month int NULL
, day_num_of_quarter int NULL
, day_num_of_year int NULL
, day_num_absolute int NULL
, day_of_week_name varchar (10) NULL
, day_of_week_abbreviation varchar (3) NULL
, julian_day_num_of_year int NULL
, julian_day_num_absolute decimal(18, 0) NULL
, is_weekday char (1) NULL
, is_US_civil_holiday char (1) NULL CONSTRAINT DF_dim_day_holiday Default('N')
, is_last_day_of_week char (1) NULL CONSTRAINT DF_dim_day_lastdow Default('N')
, is_last_day_of_month char (1) NULL CONSTRAINT DF_dim_day_lastdom Default('N')
, is_last_day_of_quarter char (1) NULL CONSTRAINT DF_dim_day_lastdoq Default('N')
, is_last_day_of_year char (1) NULL CONSTRAINT DF_dim_day_lastdoy Default('N')
, is_last_day_of_fiscal_month char (1) NULL CONSTRAINT DF_dim_day_lastdofm Default('N')
, is_last_day_of_fiscal_quarter char (1) NULL CONSTRAINT DF_dim_day_lastdofq Default('N')
, is_last_day_of_fiscal_year char (1) NULL CONSTRAINT DF_dim_day_lastdofy Default('N')
, prev_day_date datetime NULL
, prev_day_date_key int NULL
, same_weekday_year_ago_date datetime NULL
, same_weekday_year_ago_date_key int NULL
, week_of_year_begin_date datetime NULL
, week_of_year_begin_date_key int NULL
, week_of_year_end_date datetime NULL
, week_of_year_end_date_key int NULL
, week_of_month_begin_date datetime NULL
, week_of_month_begin_date_key int NULL
, week_of_month_end_date datetime NULL
, week_of_month_end_date_key int NULL
, week_of_quarter_begin_date datetime NULL
, week_of_quarter_begin_date_key int NULL
, week_of_quarter_end_date datetime NULL
, week_of_quarter_end_date_key int NULL
, week_num_of_month int NULL
, week_num_of_quarter int NULL
, week_num_of_year int NULL
, week_num_overall int NULL
, month_num_of_year int NULL
, month_num_overall int NULL
, month_name varchar (10) NULL
, month_name_abbreviation varchar (3) NULL
, month_begin_date datetime NULL
, month_begin_date_key int NULL
, month_end_date datetime NULL
, month_end_date_key int NULL
, quarter_num_of_year int NULL
, quarter_num_overall int NULL
, quarter_begin_date datetime NULL
, quarter_begin_date_key int NULL
, quarter_end_date datetime NULL
, quarter_end_date_key int NULL
, year_num int NULL
, year_begin_date datetime NULL
, year_begin_date_key int NULL
, year_end_date datetime NULL
, year_end_date_key int NULL
, YYYYMM varchar (6) NULL
, YYYYMMDD varchar (8) NULL
, DDMONYY varchar (7) NULL
, DDMONYYYY varchar (9) NULL
, fiscal_week_num_of_year int NULL
, fiscal_week_num_overall int NULL
, fiscal_week_begin_date_key int NULL
, fiscal_week_begin_date datetime NULL
, fiscal_week_end_date_key int NULL
, fiscal_week_end_date datetime NULL
, fiscal_month_num_of_year int NULL
, fiscal_month_num_overall int NULL
, fiscal_month_begin_date datetime NULL
, fiscal_month_begin_date_key int NULL
, fiscal_month_end_date datetime NULL
, fiscal_month_end_date_key int NULL
, fiscal_quarter_num_of_year int NULL
, fiscal_quarter_num_overall int NULL
, fiscal_quarter_begin_date datetime NULL
, fiscal_quarter_begin_date_key int NULL
, fiscal_quarter_end_date datetime NULL
, fiscal_quarter_end_date_key int NULL
, fiscal_year_num int NULL
, fiscal_year_begin_date datetime NULL
, fiscal_year_begin_date_key int NULL
, fiscal_year_end_date datetime NULL
, fiscal_year_end_date_key int NULL
)
GO
ALTER TABLE dim_day
ADD CONSTRAINT PK_dim_day PRIMARY KEY CLUSTERED
(
date_key
)
GO
For Oracle:
CREATE TABLE dim_day
(
date_key integer NOT NULL
, date_type varchar2 (20) NULL DEFAULT 'NORMAL'
, full_date date NULL
, day_num_of_week integer NULL
, day_num_of_month integer NULL
, day_num_of_quarter integer NULL
, day_num_of_year integer NULL
, day_num_absolute integer NULL
, day_of_week_name varchar2 (10) NULL
, day_of_week_abbreviation varchar2 (3) NULL
, julian_day_num_of_year integer NULL
, julian_day_num_absolute decimal(18, 0) NULL
, is_weekday char (1) NULL
, is_US_civil_holiday char (1) NULL DEFAULT 'N'
, is_last_day_of_week char (1) NULL DEFAULT 'N'
, is_last_day_of_month char (1) NULL DEFAULT 'N'
, is_last_day_of_quarter char (1) NULL DEFAULT 'N'
, is_last_day_of_year char (1) NULL DEFAULT 'N'
, is_last_day_of_fiscal_month char (1) NULL DEFAULT 'N'
, is_last_day_of_fiscal_quarter char (1) NULL DEFAULT 'N'
, is_last_day_of_fiscal_year char (1) NULL DEFAULT 'N'
, prev_day_date date NULL
, prev_day_date_key integer NULL
, same_weekday_year_ago_date date NULL
, same_weekday_year_ago_date_key integer NULL
, week_of_year_begin_date date NULL
, week_of_year_begin_date_key integer NULL
, week_of_year_end_date date NULL
, week_of_year_end_date_key integer NULL
, week_of_month_begin_date date NULL
, week_of_month_begin_date_key integer NULL
, week_of_month_end_date date NULL
, week_of_month_end_date_key integer NULL
, week_of_quarter_begin_date date NULL
, week_of_quarter_begin_date_key integer NULL
, week_of_quarter_end_date date NULL
, week_of_quarter_end_date_key integer NULL
, week_num_of_month integer NULL
, week_num_of_quarter integer NULL
, week_num_of_year integer NULL
, week_num_overall integer NULL
, month_num_of_year integer NULL
, month_num_overall integer NULL
, month_name varchar2 (10) NULL
, month_name_abbreviation varchar2 (3) NULL
, month_begin_date date NULL
, month_begin_date_key integer NULL
, month_end_date date NULL
, month_end_date_key integer NULL
, quarter_num_of_year integer NULL
, quarter_num_overall integer NULL
, quarter_begin_date date NULL
, quarter_begin_date_key integer NULL
, quarter_end_date date NULL
, quarter_end_date_key integer NULL
, year_num integer NULL
, year_begin_date date NULL
, year_begin_date_key integer NULL
, year_end_date date NULL
, year_end_date_key integer NULL
, YYYYMM varchar2 (6) NULL
, YYYYMMDD varchar2 (8) NULL
, DDMONYY varchar2 (7) NULL
, DDMONYYYY varchar2 (9) NULL
, fiscal_week_num_of_year integer NULL
, fiscal_week_num_overall integer NULL
, fiscal_week_begin_date_key integer NULL
, fiscal_week_begin_date date NULL
, fiscal_week_end_date_key integer NULL
, fiscal_week_end_date date NULL
, fiscal_month_num_of_year integer NULL
, fiscal_month_num_overall integer NULL
, fiscal_month_begin_date date NULL
, fiscal_month_begin_date_key integer NULL
, fiscal_month_end_date date NULL
, fiscal_month_end_date_key integer NULL
, fiscal_quarter_num_of_year integer NULL
, fiscal_quarter_num_overall integer NULL
, fiscal_quarter_begin_date date NULL
, fiscal_quarter_begin_date_key integer NULL
, fiscal_quarter_end_date date NULL
, fiscal_quarter_end_date_key integer NULL
, fiscal_year_num integer NULL
, fiscal_year_begin_date date NULL
, fiscal_year_begin_date_key integer NULL
, fiscal_year_end_date date NULL
, fiscal_year_end_date_key integer NULL
)
;
ALTER TABLE dim_day
ADD CONSTRAINT PK_dim_day PRIMARY KEY
(
date_key
)
;
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Column Definitions(Alphabetical by column name) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Send a comment:Your feedback helps us improve the site. We do not spam. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Don McMunn is a professional, business-focused consultant specializing in data warehousing and business intelligence design, development and delivery for over a decade with the Fortune 500 and SMB segments. He may be reached at: dmcmunn at ipcdesigns dot com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Due to financial concerns, and in the interest of pursuing a "green earth" policy, the light at the end of the tunnel has been turned off until further notice. We apologize in advance for the continuing pain and suffering. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||