---
title: Create a Date dimension
description: Create a Date dimension, a Mart Dimension with one row per day, to analyze your data by date.
---

[Skip to content](https://knowledge.bigenius-x.com/create-a-date-dimension#main-content)

[Contact us](https://knowledge.bigenius-x.com/kb-tickets/new?hsLang=en) [Go to Customer Portal](https://knowledge.bigenius-x.com/customer-portal?hsLang=en)

[![TRI\_Logo\_biGENIUS\_2020\_RGB\_s](https://knowledge.bigenius-x.com/hs-fs/hubfs/Marketing/TRI_Logo_biGENIUS_2020_RGB_s.png?width=150&height=42&name=TRI_Logo_biGENIUS_2020_RGB_s.png)](https://www.bigenius-x.com/)

Open main navigation

Close main navigation

- [Contact us](https://knowledge.bigenius-x.com/kb-tickets/new)
- [Go to Customer Portal](https://knowledge.bigenius-x.com/customer-portal)

 How can we help you?

- There are no suggestions because the search field is empty.

1. [biGENIUS-X Knowledge Base](https://knowledge.bigenius-x.com/?hsLang=en)
2. [Best practices](https://knowledge.bigenius-x.com/best-practices?hsLang=en)
3. [Use Cases](https://knowledge.bigenius-x.com/best-practices?hsLang=en#use-cases)

# Create a Date dimension

**Applies to**  
Platform: Microsoft SQL Server · Snowflake · Databricks · Fabric Lakehouse  
Architecture: Data Vault · Dimensional · Data Mart

Create a Date dimension, a [Mart Dimension](https://knowledge.bigenius-x.com/mart-dimension?hsLang=en) with one row per day, to analyze your data by date. Sources rarely deliver such a table, so you first create the date rows on your platform and then model the dimension on them. Afterwards the Mart layer has the Mart Dimension `D_Date`.

### Prerequisites

- A project with a Mart layer: Vault and Mart, or Dimensional and Mart. With a separate Data Mart project, build the Reference Table of the Data Vault path in the linked Data Vault project and import it, see [Model a Data Mart solution](https://knowledge.bigenius-x.com/model-a-data-mart-solution?hsLang=en#start-a-data-mart-project).
- The right to create a database, table or view in a source system of the project whose discovery reaches it, see [Add a Source System](https://knowledge.bigenius-x.com/add-a-source-system?hsLang=en).

### Create the date source data

Create the date rows with the code for your platform. Each variant delivers one row per day, with the keys and columns of the day, month, quarter and year. Weekdays run from Sunday (1) to Saturday (7), and weeks start on Sunday. The Microsoft SQL Server code covers 1900 to 2199, the others 2000 to 2099.

#### Microsoft SQL Server

Run each step as its own script. The `GO` lines separate the batches.

1. Create the database `Manual_Data`:
   
   ```
   USE [master];
   GO
   CREATE DATABASE [Manual_Data];
   GO
   ```
2. Create the function `GetDateRange()`, which returns one row per day:
   
   ```
   USE [Manual_Data];
   GO
   CREATE FUNCTION [dbo].[GetDateRange] (
        @dtFrom                  DATETIME
       ,@dtTo                    DATETIME
       ,@fiscalYearOffsetInMonth INT
   )
   RETURNS @Result TABLE (
        [DateKey]                INT PRIMARY KEY
       ,[Date]                   DATETIME
       ,[YearKey]                INT
       ,[YearNumber]             INT
       ,[Year]                   VARCHAR(30)
       ,[QuarterKey]             INT
       ,[QuarterNumber]          TINYINT
       ,[Quarter]                VARCHAR(30)
       ,[MonthKey]               INT
       ,[MonthNumber]            TINYINT
       ,[Month]                  VARCHAR(30)
       ,[MonthName]              VARCHAR(30)
       ,[FirstDateInMonth]       DATETIME
       ,[LastDateInMonth]        DATETIME
       ,[DayKey]                 INT
       ,[Day]                    VARCHAR(30)
       ,[DayNumberOfWeekKey]     TINYINT
       ,[DayNumberOfWeekNumber]  TINYINT
       ,[DayNumberOfWeekName]    VARCHAR(30)
       ,[DayNumberOfMonth]       TINYINT
       ,[DayNumberOfYear]        SMALLINT
       ,[WeekKey]                INT
       ,[WeekNumber]             SMALLINT
       ,[WeekName]               VARCHAR(30)
       ,[WeekNumberOfYear]       SMALLINT
   )
   AS
   BEGIN
       DECLARE
            @dt               DATETIME
           ,@dtFiscal         DATETIME
           ,@id               INT
           ,@year             INT
           ,@yearName         CHAR(4)
           ,@semester         INT
           ,@quarter          INT
           ,@month            INT
           ,@firstDateInMonth DATE
           ,@yearFiscal       INT
           ,@yearNameFiscal   CHAR(4)
           ,@semesterFiscal   INT
           ,@quarterFiscal    INT
           ,@monthFiscal      INT
           ,@day              INT
           ,@dayOfWeek        TINYINT;
   
       SET @dt = @dtFrom;
       WHILE @dt <= @dtTo
       BEGIN
           SELECT
                @year     = YEAR(@dt)
               ,@yearName = CAST(@year AS CHAR(4))
               ,@quarter  = DATEPART(q, @dt)
               ,@semester = CASE WHEN @quarter <= 2 THEN 1 ELSE 2 END
               ,@month    = MONTH(@dt)
               ,@firstDateInMonth = CAST(
                    CAST(@year AS NVARCHAR(10)) + '-'
                    + CAST(@month AS NVARCHAR(10)) + '-01' AS DATE)
               ,@day      = DAY(@dt)
               ,@id       = @year * 10000 + @month * 100 + @day
               ,@dtFiscal = DATEADD(m, @fiscalYearOffsetInMonth, @dt)
               ,@yearFiscal     = YEAR(@dtFiscal)
               ,@yearNameFiscal = CAST(@yearFiscal AS CHAR(4))
               ,@quarterFiscal  = DATEPART(q, @dtFiscal)
               ,@semesterFiscal =
                    CASE WHEN @quarterFiscal <= 2 THEN 1 ELSE 2 END
               ,@monthFiscal    = MONTH(@dtFiscal)
               ,@dayOfWeek      = DATEPART(dw, @dt);
   
           INSERT INTO @Result (
                [DateKey], [Date]
               ,[YearKey], [YearNumber], [Year]
               ,[QuarterKey], [QuarterNumber], [Quarter]
               ,[MonthKey], [MonthNumber], [Month], [MonthName]
               ,[FirstDateInMonth], [LastDateInMonth]
               ,[DayKey], [Day]
               ,[DayNumberOfWeekKey], [DayNumberOfWeekNumber]
               ,[DayNumberOfWeekName]
               ,[DayNumberOfMonth], [DayNumberOfYear]
               ,[WeekKey], [WeekNumber], [WeekName], [WeekNumberOfYear]
           )
           VALUES (
                @id                               -- DateKey
               ,@dt                               -- Date
               ,@year                             -- YearKey
               ,@year                             -- YearNumber
               ,@yearName                         -- Year
               ,@year * 10 + @quarter             -- QuarterKey
               ,@quarter                          -- QuarterNumber
               ,@yearName + '/Q'
                    + CAST(@quarter AS CHAR(1))   -- Quarter
               ,@year * 100 + @month              -- MonthKey
               ,@month                            -- MonthNumber
               ,DATENAME(mm, @dt) + ' '
                    + CAST(@yearName AS VARCHAR(4)) -- Month
               ,DATENAME(mm, @dt)                 -- MonthName
               ,@firstDateInMonth                 -- FirstDateInMonth
               ,DATEADD(DAY, -1,
                    DATEADD(MONTH, 1, @firstDateInMonth)) -- LastDateInMonth
               ,@id                               -- DayKey
               ,DATENAME(mm, @dt) + ' '
                    + CAST(DAY(@dt) AS VARCHAR(2)) + ', '
                    + CAST(YEAR(@dt) AS VARCHAR(4)) -- Day
               ,@dayOfWeek                        -- DayNumberOfWeekKey
               ,@dayOfWeek                        -- DayNumberOfWeekNumber
               ,CASE @dayOfWeek
                    WHEN 1 THEN 'Sunday'
                    WHEN 2 THEN 'Monday'
                    WHEN 3 THEN 'Tuesday'
                    WHEN 4 THEN 'Wednesday'
                    WHEN 5 THEN 'Thursday'
                    WHEN 6 THEN 'Friday'
                    WHEN 7 THEN 'Saturday'
                END                               -- DayNumberOfWeekName
               ,@day                              -- DayNumberOfMonth
               ,DATEPART(dy, @dt)                 -- DayNumberOfYear
               ,@year * 100 + DATEPART(wk, @dt)   -- WeekKey
               ,DATEPART(wk, @dt)                 -- WeekNumber
               ,@yearName + '/W' + RIGHT('00'
                    + CAST(DATEPART(wk, @dt) AS VARCHAR(2)), 2) -- WeekName
               ,DATEPART(wk, @dt)                 -- WeekNumberOfYear
           );
   
           SET @dt = DATEADD(day, 1, @dt);
       END;
       RETURN;
   END;
   GO
   ```
3. Create the table `DateRange`:
   
   ```
   USE [Manual_Data];
   GO
   CREATE TABLE [dbo].[DateRange] (
        [DateKey]                INT PRIMARY KEY
       ,[Date]                   DATETIME
       ,[YearKey]                INT
       ,[YearNumber]             INT
       ,[Year]                   VARCHAR(30)
       ,[QuarterKey]             INT
       ,[QuarterNumber]          TINYINT
       ,[Quarter]                VARCHAR(30)
       ,[MonthKey]               INT
       ,[MonthNumber]            TINYINT
       ,[Month]                  VARCHAR(30)
       ,[MonthName]              VARCHAR(30)
       ,[FirstDateInMonth]       DATETIME
       ,[LastDateInMonth]        DATETIME
       ,[DayKey]                 INT
       ,[Day]                    VARCHAR(30)
       ,[DayNumberOfWeekKey]     TINYINT
       ,[DayNumberOfWeekNumber]  TINYINT
       ,[DayNumberOfWeekName]    VARCHAR(30)
       ,[DayNumberOfMonth]       TINYINT
       ,[DayNumberOfYear]        SMALLINT
       ,[WeekKey]                INT
       ,[WeekNumber]             SMALLINT
       ,[WeekName]               VARCHAR(30)
       ,[WeekNumberOfYear]       SMALLINT
   );
   GO
   ```
4. Fill the table:
   
   ```
   USE [Manual_Data];
   GO
   SET LANGUAGE us_english;
   INSERT INTO [dbo].[DateRange]
   SELECT *
   FROM [dbo].[GetDateRange](
        CAST(N'1900-01-01' AS DATETIME)
       ,CAST(N'2199-12-31' AS DATETIME)
       ,0);
   GO
   ```

Check: `SELECT COUNT(*) FROM [dbo].[DateRange]` returns `109573`. The row with the `DateKey` `20270101` has the `DayNumberOfWeekName` `Friday`.

#### Snowflake

Create the view `DATERANGE` in the database and schema of your source data:

```
CREATE OR REPLACE VIEW <database>.<schema>.DATERANGE
AS
WITH precalculation AS
(
SELECT
      -- 36525 days: 2000-01-01 to 2099-12-31
      DATEADD(day, ROW_NUMBER() OVER (ORDER BY SEQ8()) - 1,
              '2000-01-01'::DATE) AS dt
      , YEAR(dt) AS year
      , CAST(year AS VARCHAR(4)) AS yearName
      , QUARTER(dt) AS quarter
      , MONTH(dt) AS month
      , DATE_TRUNC('MONTH', dt) AS firstDateInMonth
      , DAY(dt) AS day
      , year * 10000 + month * 100 + day AS id
      -- 1 = Sunday ... 7 = Saturday, independent of WEEK_START
      , MOD(DAYOFWEEKISO(dt), 7) + 1 AS dayOfWeek
      -- weeks start on Sunday, week 1 holds 1 January
      , CAST(FLOOR((DAYOFYEAR(dt) - 1
          + MOD(DAYOFWEEKISO(DATE_TRUNC('YEAR', dt)), 7)) / 7) + 1
          AS INTEGER) AS week
FROM TABLE(GENERATOR(ROWCOUNT => 36525))
)
SELECT
      id AS DateKey
      ,dt AS Date
      ,year AS YearKey
      ,year AS YearNumber
      ,yearName AS Year
      ,year * 10 + quarter AS QuarterKey
      ,quarter AS QuarterNumber
      ,yearName || '/Q' || quarter AS Quarter
      ,year * 100 + month AS MonthKey
      ,month AS MonthNumber
      ,TO_CHAR(dt, 'MMMM') || ' ' || yearName AS Month
      ,TO_CHAR(dt, 'MMMM') AS MonthName
      ,firstDateInMonth AS FirstDateInMonth
      ,LAST_DAY(dt) AS LastDateInMonth
      ,id AS DayKey
      ,TO_CHAR(dt, 'MMMM') || ' ' || day || ', ' || yearName AS Day
      ,dayOfWeek AS DayNumberOfWeekKey
      ,dayOfWeek AS DayNumberOfWeekNumber
      ,DECODE(dayOfWeek, 1, 'Sunday', 2, 'Monday', 3, 'Tuesday',
              4, 'Wednesday', 5, 'Thursday', 6, 'Friday',
              7, 'Saturday') AS DayNumberOfWeekName
      ,day AS DayNumberOfMonth
      ,DAYOFYEAR(dt) AS DayNumberOfYear
      ,year * 100 + week AS WeekKey
      ,week AS WeekNumber
      ,yearName || '/W' || LPAD(week, 2, '0') AS WeekName
      ,week AS WeekNumberOfYear
FROM precalculation;
```

Snowflake stores the column names in upper case, for example `DAYKEY`; use these names in the steps below.

#### Databricks

Create the view `daterange` in a notebook, in the catalog and schema of your source data:

```
%sql
CREATE OR REPLACE VIEW <catalog>.<schema>.daterange AS
WITH precalculation AS (
  SELECT
    dt,
    YEAR(dt) AS year,
    CAST(YEAR(dt) AS STRING) AS yearName,
    QUARTER(dt) AS quarter,
    MONTH(dt) AS month,
    DAY(dt) AS day,
    YEAR(dt) * 10000 + MONTH(dt) * 100 + DAY(dt) AS id,
    -- 1 = Sunday ... 7 = Saturday
    DAYOFWEEK(dt) AS dayOfWeek,
    -- weeks start on Sunday, week 1 holds 1 January
    CAST(FLOOR((DAYOFYEAR(dt) - 1
      + DAYOFWEEK(TRUNC(dt, 'YEAR')) - 1) / 7) + 1 AS INT) AS week
  FROM (
    SELECT explode(sequence(
      DATE'2000-01-01', DATE'2099-12-31', INTERVAL 1 DAY)) AS dt
  )
)
SELECT
  id AS DateKey,
  dt AS Date,
  year AS YearKey,
  year AS YearNumber,
  yearName AS Year,
  year * 10 + quarter AS QuarterKey,
  quarter AS QuarterNumber,
  CONCAT(yearName, '/Q', quarter) AS Quarter,
  year * 100 + month AS MonthKey,
  month AS MonthNumber,
  CONCAT(date_format(dt, 'MMMM'), ' ', yearName) AS Month,
  date_format(dt, 'MMMM') AS MonthName,
  TRUNC(dt, 'MM') AS FirstDateInMonth,
  LAST_DAY(dt) AS LastDateInMonth,
  id AS DayKey,
  CONCAT(date_format(dt, 'MMMM'), ' ', day, ', ', yearName) AS Day,
  dayOfWeek AS DayNumberOfWeekKey,
  dayOfWeek AS DayNumberOfWeekNumber,
  date_format(dt, 'EEEE') AS DayNumberOfWeekName,
  day AS DayNumberOfMonth,
  DAYOFYEAR(dt) AS DayNumberOfYear,
  year * 100 + week AS WeekKey,
  week AS WeekNumber,
  CONCAT(yearName, '/W', lpad(week, 2, '0')) AS WeekName,
  week AS WeekNumberOfYear
FROM precalculation
```

#### Fabric Lakehouse

Create the table `DATERANGE` in a PySpark notebook cell, in your lakehouse and schema:

```
from datetime import date, timedelta
from pyspark.sql import functions as F

# One row per day from 2000-01-01 to 2099-12-31
start_date, end_date = date(2000, 1, 1), date(2099, 12, 31)
days = (end_date - start_date).days + 1
df = spark.createDataFrame(
    [(start_date + timedelta(days=i),) for i in range(days)], ["dt"])

# Helper columns with a prefix: column names are not case
# sensitive, so "year" and "Year" would be the same column.
df = (
    df.withColumn("p_year", F.year("dt"))
      .withColumn("p_yname", F.col("p_year").cast("string"))
      .withColumn("p_quarter", F.quarter("dt"))
      .withColumn("p_month", F.month("dt"))
      .withColumn("p_day", F.dayofmonth("dt"))
      .withColumn("p_mname", F.date_format("dt", "MMMM"))
      # 1 = Sunday ... 7 = Saturday
      .withColumn("p_dow", F.dayofweek("dt"))
      # weeks start on Sunday, week 1 holds 1 January
      .withColumn("p_week", (F.floor(
          (F.dayofyear("dt") - 1
           + F.dayofweek(F.trunc("dt", "year")) - 1) / 7) + 1)
          .cast("int"))
)

key = F.col("p_year") * 10000 + F.col("p_month") * 100 + F.col("p_day")
df = df.select(
    key.alias("DateKey"),
    F.col("dt").alias("Date"),
    F.col("p_year").alias("YearKey"),
    F.col("p_year").alias("YearNumber"),
    F.col("p_yname").alias("Year"),
    (F.col("p_year") * 10 + F.col("p_quarter")).alias("QuarterKey"),
    F.col("p_quarter").alias("QuarterNumber"),
    F.concat("p_yname", F.lit("/Q"),
             F.col("p_quarter").cast("string")).alias("Quarter"),
    (F.col("p_year") * 100 + F.col("p_month")).alias("MonthKey"),
    F.col("p_month").alias("MonthNumber"),
    F.concat_ws(" ", "p_mname", "p_yname").alias("Month"),
    F.col("p_mname").alias("MonthName"),
    F.trunc("dt", "month").alias("FirstDateInMonth"),
    F.last_day("dt").alias("LastDateInMonth"),
    key.alias("DayKey"),
    F.format_string("%s %d, %s", "p_mname", "p_day", "p_yname")
     .alias("Day"),
    F.col("p_dow").alias("DayNumberOfWeekKey"),
    F.col("p_dow").alias("DayNumberOfWeekNumber"),
    F.date_format("dt", "EEEE").alias("DayNumberOfWeekName"),
    F.col("p_day").alias("DayNumberOfMonth"),
    F.dayofyear("dt").alias("DayNumberOfYear"),
    (F.col("p_year") * 100 + F.col("p_week")).alias("WeekKey"),
    F.col("p_week").alias("WeekNumber"),
    F.format_string("%s/W%02d", "p_yname", "p_week").alias("WeekName"),
    F.col("p_week").alias("WeekNumberOfYear"),
)

# Save as a table: replace <lakehouse> and <schema>; in a lakehouse
# without schemas, write "<lakehouse>.DATERANGE"
df.write.mode("overwrite").saveAsTable(
    "<lakehouse>.<schema>.DATERANGE")
```

Check on Snowflake, Databricks and Fabric Lakehouse: `SELECT COUNT(*)` on `DATERANGE` returns `36525`. The row with the `DateKey` `20270101` has the `DayNumberOfWeekName` `Friday`.

### Settings for both paths

These settings keep the date objects free of errors and warnings:

- Business keys not nullable: in **Edit Term** of each business key, clear **Nullable**, see [Edit a Term](https://knowledge.bigenius-x.com/edit-a-term?hsLang=en). Otherwise the warning [ID-10013](https://knowledge.bigenius-x.com/business-key-terms-not-nullable-business-rule?hsLang=en) appears.
- Entities: set the [Historization Type](https://knowledge.bigenius-x.com/historization-type-term-and-relationship?hsLang=en) of each descriptive term and of each relationship to `SCD1`. A relationship without one raises the error [ID-10009](https://knowledge.bigenius-x.com/supported-historization-types-business-rule?hsLang=en); `SCD2` terms raise the warnings [ID-10028](https://knowledge.bigenius-x.com/effective-timestamp-mapped-business-rule?hsLang=en) and [ID-10059](https://knowledge.bigenius-x.com/mixed-historization-types-business-rule?hsLang=en).

### Model the dimension in Data Vault

In Data Vault, the date rows go through a [Reference Table](https://knowledge.bigenius-x.com/reference-table?hsLang=en) into the Mart Dimension, here in a Vault and Mart project:

![Data lineage of the Mart Dimension D\_Date in a Vault and Mart project: the Source DateRange feeds the Stage DateRange, which feeds the Reference Table DateRange, which feeds the Mart Dimension D\_Date.](https://knowledge.bigenius-x.com/hs-fs/hubfs/knowledge_base_screenshots/create-a-date-dimension-vault-and-mart-lineage.png?width=688&height=37&name=create-a-date-dimension-vault-and-mart-lineage.png)

1. Discover the date table or view and create a Source from it, see [Create Source Objects from a Discovery](https://knowledge.bigenius-x.com/create-source-objects-from-a-discovery?hsLang=en).
2. Create a [Stage](https://knowledge.bigenius-x.com/stage?hsLang=en) from the Source.
3. Create a Reference Table from the Stage, with the business key `DayKey` and all other terms.
4. Create the Mart Dimension `D_Date` from the Reference Table, with the business key `DayKey` and all other terms.

### Model the dimension in Dimensional

In Dimensional, one [Entity](https://knowledge.bigenius-x.com/entity?hsLang=en) per level holds the date rows, and the Mart Dimension joins the four Entities:

![Data lineage of the Mart Dimension D\_Date in a Dimensional and Mart project: the Source DateRange feeds the Stage DateRange, which feeds the Entities Date\_Day, Date\_Month, Date\_Quarter and Date\_Year. All four Entities feed the Mart Dimension D\_Date.](https://knowledge.bigenius-x.com/hs-fs/hubfs/knowledge_base_screenshots/create-a-date-dimension-dimensional-lineage.png?width=688&height=159&name=create-a-date-dimension-dimensional-lineage.png)

#### Create the Entities

1. Discover the date table or view and create a Source from it, see [Create Source Objects from a Discovery](https://knowledge.bigenius-x.com/create-source-objects-from-a-discovery?hsLang=en).
2. Create a Stage from the Source.
3. Create the Entity `Date_Year` with the business key `YearKey` and the terms `YearNumber` and `Year`. In **Edit Dataflow**, set its Deduplication Method to `Distinct`, see [Deduplication Method (Dataflow)](https://knowledge.bigenius-x.com/deduplication-method-dataflow?hsLang=en#where-to-set-it).
4. Create the Entity `Date_Quarter` with the business key `QuarterKey`, the terms `QuarterNumber` and `Quarter`, and the Deduplication Method `Distinct`. In the wizard, tick `Date_Year` in [Select Relationship](https://knowledge.bigenius-x.com/wizard-step-select-relationship?hsLang=en), set the Historization Type `SCD1` in [Define Roles](https://knowledge.bigenius-x.com/wizard-step-create-relations-with-role?hsLang=en), and map `YearKey` to `FK_Date_Year_YearKey` in [Map Foreign Key Terms](https://knowledge.bigenius-x.com/wizard-step-map-foreign-key-terms?hsLang=en).
5. Create the Entity `Date_Month` with the business key `MonthKey`, the terms `MonthNumber`, `Month`, `MonthName`, `FirstDateInMonth` and `LastDateInMonth`, and the Deduplication Method `Distinct`. Relate it to `Date_Quarter` as in step 4, with `QuarterKey` mapped to `FK_Date_Quarter_QuarterKey`.
6. Create the Entity `Date_Day` with the business key `DayKey`, the terms `Date` and `Day`, and the terms whose names start with `DayNumberOf` or `Week`. Relate it to `Date_Month` as in step 4, with `MonthKey` mapped to `FK_Date_Month_MonthKey`.

#### Create the Mart Dimension

1. Create the Mart Dimension `D_Date` from `Date_Day` with the wizard, with the business key `DayKey` and all other terms except `FK_Date_Month_MonthKey`. `Date_Day` is the source `s1`.
2. In **Manage Term Mappings** of `D_Date`, add `Date_Month`, `Date_Quarter` and `Date_Year` to the dataflow set, see [Add a Model Object to a Dataflow Set](https://knowledge.bigenius-x.com/add-a-model-object-into-a-data-flow-set?hsLang=en). In **Edit Dataflow Model Object** of each, set the alias, Inner Join and the join expression: `s2` with `s1.FK_Date_Month_MonthKey = s2.MonthKey`, `s3` with `s2.FK_Date_Quarter_QuarterKey = s3.QuarterKey`, `s4` with `s3.FK_Date_Year_YearKey = s4.YearKey`.
3. On the source cards `s2`, `s3` and `s4`, choose **Auto Map all** with **Create new terms automatically**, see [Map or unmap a Source Term with a Target Term](https://knowledge.bigenius-x.com/map-a-source-term-with-a-target-term?hsLang=en).
4. In **Manage Terms** of `D_Date`, delete `FK_Date_Quarter_QuarterKey` and `FK_Date_Year_YearKey`. For `MonthKey`, `QuarterKey` and `YearKey`, clear **Business Key**, which Auto Map all copied from the Entities, and set the Historization Type `SCD1`.

`D_Date` now holds the terms of the day, month, quarter and year, with `DayKey` as its only business key:

![Dataflow of the Mart Dimension D\_Date: Date\_Day as s1; Date\_Month as s2 with the inner join s1.FK\_Date\_Month\_MonthKey = s2.MonthKey; Date\_Quarter as s3 with s2.FK\_Date\_Quarter\_QuarterKey = s3.QuarterKey; Date\_Year as s4 with s3.FK\_Date\_Year\_YearKey = s4.YearKey.](https://knowledge.bigenius-x.com/hs-fs/hubfs/knowledge_base_screenshots/create-a-date-dimension-d-date-dataflow.png?width=654&height=398&name=create-a-date-dimension-d-date-dataflow.png)

### Check the result

Before you generate, check that the cards of the date objects show no error or warning icon. Then [generate the artifacts](https://knowledge.bigenius-x.com/generate-artifacts?hsLang=en), deploy and load the project, see the deployment and load articles of your platform under Related articles. `D_Date` then holds one row per `DayKey` that the Stage delivers.

### Failure symptoms and recovery

#### Filling DateRange fails with a duplicate key

Message: `Violation of PRIMARY KEY constraint '<constraint name>'. Cannot insert duplicate key in object 'dbo.DateRange'.`  
Cause: the table already holds rows from an earlier run of the fill step.  
Fix: run `TRUNCATE TABLE [dbo].[DateRange];` and fill the table again.

#### Filling DateRange fails or the weekdays are wrong

Message: `The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.`  
Cause: the session language, for example German, reads the dates as year-day-month and starts weeks on Monday.  
Fix: run the fill step with `SET LANGUAGE us_english;` as shown, after `TRUNCATE TABLE [dbo].[DateRange];`.

### Related articles

- Previous: [Create Source Objects from a Discovery](https://knowledge.bigenius-x.com/create-source-objects-from-a-discovery?hsLang=en)
- Next: 
    - Microsoft SQL Server: [Deployment](https://knowledge.bigenius-x.com/microsoft-sql-server-deployment?hsLang=en), [Load data - Native load control](https://knowledge.bigenius-x.com/microsoft-sql-server-load-data-native-load-control?hsLang=en)
    - Snowflake: [Deployment](https://knowledge.bigenius-x.com/snowflake-deployment?hsLang=en), [Load data - Native load control](https://knowledge.bigenius-x.com/snowflake-load-data-native-load-control?hsLang=en)
    - Databricks: [Deployment](https://knowledge.bigenius-x.com/databricks-deployment?hsLang=en), [Load data - Native load control](https://knowledge.bigenius-x.com/databricks-load-data-native-load-control?hsLang=en)
    - Fabric Lakehouse: [Deployment](https://knowledge.bigenius-x.com/fabric-lakehouse-deployment?hsLang=en), [Load data - Native load control](https://knowledge.bigenius-x.com/fabric-lakehouse-load-data-native-load-control?hsLang=en)
- Reference: [Mart Dimension](https://knowledge.bigenius-x.com/mart-dimension?hsLang=en), [Reference Table](https://knowledge.bigenius-x.com/reference-table?hsLang=en), [Entity](https://knowledge.bigenius-x.com/entity?hsLang=en), [Stage](https://knowledge.bigenius-x.com/stage?hsLang=en), [Deduplication Method (Dataflow)](https://knowledge.bigenius-x.com/deduplication-method-dataflow?hsLang=en), [Historization Type (Term and Relationship)](https://knowledge.bigenius-x.com/historization-type-term-and-relationship?hsLang=en), [Business Key Terms not nullable (Business Rule)](https://knowledge.bigenius-x.com/business-key-terms-not-nullable-business-rule?hsLang=en), [Supported Historization Types (Business Rule)](https://knowledge.bigenius-x.com/supported-historization-types-business-rule?hsLang=en), [Foreign Key Mapping (Business Rule)](https://knowledge.bigenius-x.com/foreign-key-mapping-business-rule?hsLang=en), [Effective Timestamp mapped (Business Rule)](https://knowledge.bigenius-x.com/effective-timestamp-mapped-business-rule?hsLang=en), [Mixed historization types (Business Rule)](https://knowledge.bigenius-x.com/mixed-historization-types-business-rule?hsLang=en)
- See also: [Create a Model Object with the wizard](https://knowledge.bigenius-x.com/create-a-model-object-with-the-wizard?hsLang=en), [Wizard step - Select Relationship](https://knowledge.bigenius-x.com/wizard-step-select-relationship?hsLang=en), [Wizard step - Define Roles](https://knowledge.bigenius-x.com/wizard-step-create-relations-with-role?hsLang=en), [Wizard step - Map Foreign Key Terms](https://knowledge.bigenius-x.com/wizard-step-map-foreign-key-terms?hsLang=en), [Edit a Relationship](https://knowledge.bigenius-x.com/edit-a-relationship?hsLang=en), [Edit a Term](https://knowledge.bigenius-x.com/edit-a-term?hsLang=en), [Edit a Dataflow Set](https://knowledge.bigenius-x.com/edit-a-data-flow-set?hsLang=en), [Add a Model Object to a Dataflow Set](https://knowledge.bigenius-x.com/add-a-model-object-into-a-data-flow-set?hsLang=en), [Map or unmap a Source Term with a Target Term](https://knowledge.bigenius-x.com/map-a-source-term-with-a-target-term?hsLang=en), [Delete a Term](https://knowledge.bigenius-x.com/delete-a-term?hsLang=en), [Generate artifacts](https://knowledge.bigenius-x.com/generate-artifacts?hsLang=en)

- [Getting started](https://knowledge.bigenius-x.com/getting-started?hsLang=en#main-content)

    - [Guidelines](https://knowledge.bigenius-x.com/getting-started?hsLang=en#guidelines)
    - [Start working](https://knowledge.bigenius-x.com/getting-started?hsLang=en#start-working)
    - [Account](https://knowledge.bigenius-x.com/getting-started?hsLang=en#account)
- [General overview](https://knowledge.bigenius-x.com/general-overview?hsLang=en)
- [Artificial Intelligence](https://knowledge.bigenius-x.com/artificial-intelligence?hsLang=en#main-content)

    - [MCP server](https://knowledge.bigenius-x.com/artificial-intelligence?hsLang=en#mcp-server)
- [Application Modules](https://knowledge.bigenius-x.com/application-modules?hsLang=en#main-content)

    - [Administration](https://knowledge.bigenius-x.com/application-modules?hsLang=en#administration)
    - [Solutions](https://knowledge.bigenius-x.com/application-modules?hsLang=en#solutions)
    - [Global Features](https://knowledge.bigenius-x.com/application-modules?hsLang=en#global-features)
    - [Projects](https://knowledge.bigenius-x.com/application-modules?hsLang=en#projects)
    - [Branches](https://knowledge.bigenius-x.com/application-modules?hsLang=en#branches)
    - [Data Connections](https://knowledge.bigenius-x.com/application-modules?hsLang=en#data-connections)
    - [Dataflow Modeling - Overview](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-overview)
    - [Dataflow Modeling - Wizard Steps](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-wizard-steps)
    - [Dataflow Modeling - Terms](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-terms)
    - [Dataflow Modeling - Term Mapping](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-term-mapping)
    - [Dataflow Modeling - Relationships](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-relationships)
    - [Dataflow Modeling - Data Quality](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-data-quality)
    - [Dataflow Modeling - Indexes](https://knowledge.bigenius-x.com/application-modules?hsLang=en#dataflow-modeling-indexes)
    - [Relationship Modeling](https://knowledge.bigenius-x.com/application-modules?hsLang=en#relationship-modeling)
    - [Generate Artifacts](https://knowledge.bigenius-x.com/application-modules?hsLang=en#generate-artifacts)
    - [Project Settings](https://knowledge.bigenius-x.com/application-modules?hsLang=en#project-settings)
    - [Data Marketplace](https://knowledge.bigenius-x.com/application-modules?hsLang=en#data-marketplace)
- [Generators](https://knowledge.bigenius-x.com/generators?hsLang=en#main-content)

    - [Databricks](https://knowledge.bigenius-x.com/generators?hsLang=en#databricks)
    - [Databricks dbt](https://knowledge.bigenius-x.com/generators?hsLang=en#databricks-dbt)
    - [Fabric Lakehouse](https://knowledge.bigenius-x.com/generators?hsLang=en#fabric-lakehouse)
    - [Fabric Warehouse](https://knowledge.bigenius-x.com/generators?hsLang=en#fabric-warehouse)
    - [Microsoft SQL Server](https://knowledge.bigenius-x.com/generators?hsLang=en#microsoft-sql-server)
    - [Oracle](https://knowledge.bigenius-x.com/generators?hsLang=en#oracle)
    - [Snowflake](https://knowledge.bigenius-x.com/generators?hsLang=en#snowflake)
    - [Snowflake dbt](https://knowledge.bigenius-x.com/generators?hsLang=en#snowflake-dbt)
    - [Artifacts](https://knowledge.bigenius-x.com/generators?hsLang=en#artifacts)
    - [Replace Placeholders](https://knowledge.bigenius-x.com/generators?hsLang=en#replace-placeholders)
    - [Target solution environment](https://knowledge.bigenius-x.com/generators?hsLang=en#target-solution-environment)
    - [Deployment](https://knowledge.bigenius-x.com/generators?hsLang=en#deployment)
    - [Deployment with an Azure DevOps pipeline](https://knowledge.bigenius-x.com/generators?hsLang=en#deployment-with-an-azure-devops-pipeline)
    - [Delta Deployment](https://knowledge.bigenius-x.com/generators?hsLang=en#delta-deployment)
    - [Load control environment](https://knowledge.bigenius-x.com/generators?hsLang=en#load-control-environment)
    - [Load data with a native load control](https://knowledge.bigenius-x.com/generators?hsLang=en#load-data-with-a-native-load-control)
    - [Load data with Apache Airflow](https://knowledge.bigenius-x.com/generators?hsLang=en#load-data-with-apache-airflow)
    - [Model Object Type](https://knowledge.bigenius-x.com/generators?hsLang=en#model-object-type)
    - [Properties](https://knowledge.bigenius-x.com/generators?hsLang=en#properties)
    - [Default Terms](https://knowledge.bigenius-x.com/generators?hsLang=en#default-terms)
- [Discovery application](https://knowledge.bigenius-x.com/discovery-application?hsLang=en#main-content)

    - [Discovery configurations](https://knowledge.bigenius-x.com/discovery-application?hsLang=en#discovery-configurations)
- [Best practices](https://knowledge.bigenius-x.com/best-practices?hsLang=en#main-content)

    - [Modeling Approaches](https://knowledge.bigenius-x.com/best-practices?hsLang=en#modeling-approaches)
    - [Use Cases](https://knowledge.bigenius-x.com/best-practices?hsLang=en#use-cases)
    - [Business Rules](https://knowledge.bigenius-x.com/best-practices?hsLang=en#business-rules)
    - [Data Quality Rules](https://knowledge.bigenius-x.com/best-practices?hsLang=en#data-quality-rules)
- [FAQs](https://knowledge.bigenius-x.com/faqs?hsLang=en)
- [Product Release Notes](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#main-content)

    - [SaaS Application](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#saas-application)
    - [Discovery application](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#discovery-application)
    - [Generators](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#generators)
    - [MCP server](https://knowledge.bigenius-x.com/product-release-notes?hsLang=en#mcp-server)
- [Legal Documents](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#main-content)

    - [Current legal docs](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#current-legal-docs)
    - [Software Product and Limits](https://knowledge.bigenius-x.com/legal-documents?hsLang=en#software-product-and-limits)

- [Contact us](https://knowledge.bigenius-x.com/kb-tickets/new?hsLang=en)
- [Customer Portal](https://knowledge.bigenius-x.com/customer-portal)
- [Sign in](https://knowledge.bigenius-x.com/_hcms/mem/login)

[![biGENIUS logo](https://knowledge.bigenius-x.com/hubfs/TRI_Logo_biGENIUS_2020_RGB-1.svg "biGENIUS logo")](https://www.bigenius-x.com)

<https://www.linkedin.com/company/bigenius> <https://www.youtube.com/@biGENIUS_DWA>

All rights reserved © 2025, biGENIUS AG