SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Functions for using the keys from the Date and Time Dimensions

By Joshua A. Walker, 2009/03/12

Total article views: 1519 | Views in the last 30 days: 74

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.

By Joshua A. Walker, 2009/03/12

Total article views: 1519 | Views in the last 30 days: 74
Your response
 
 
Related tags

Data Warehousing     DateTime    
DataWarehouse     Dimensions    
 
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com