Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Functions for using the keys from the Date and Time Dimensions

By Joshua A. Walker,

These are functions related to the date and time dimensions created by the script posted here:http://www.sqlservercentral.com/scripts/TSQL/65762/

 

There are three functions. Copy them and run them in the same place where you have your dim_Date and dim_Time dimension tables.

There are example calls for each function in the comments section of each function.

Sample calls:

SELECT dbo.WHSE_fnGetDateKey(getdate()) [DATEID], dbo.WHSE_fnGetTimeKey(getdate()) [TIMEID]


SELECT dbo.[WHSE_fnGetDateTimeWKey](20090310,50000)

 

This is a vital piece for quickly and easily converting your datetime strings into the IDs for the date and time dimensions prior to storage in your fact tables.

Total article views: 4201 | Views in the last 30 days: 18
 
Related Articles
FORUM

Advantages of Time Dimension

Advantages of Time Dimension

FORUM

"function"

"function"

SCRIPT

Date Dimension

Here is a simple script that I use to create a Date Dimension table.

ARTICLE

Stairway to MDX - Level 5: Members, and an Introduction to the MDX Members Functions

Bill explains what is meant by a 'Member' and 'Member function' in MDX. A member is an item in a di...

FORUM

How to Convert nx1 dimension table to 1x1 dimension table

How to Convert nx1 dimension table to 1x1 dimension table

Tags
data warehousing    
datawarehouse    
datetime    
dimensions    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones