Relative Date Dimension Table (DATE_DIM_VIEW):

One of the many problems analytics professionals need to accommodate on a daily basis is time. Effectively managing time in the field of analytics doesn’t require a new wristwatch, but having the ability to easily slice and dice data on a daily basis. Without a sophisticated date calendar to filter sales by year-to-date versus last-year, analytics professionals waste countless hours every day re-enabling logic that could be provided within a database table.

Mondo Analytics believes so strongly in modern database efficiencies, we’ve developed and shared a standard yearly calendar using the Snowflake Data Exchange. The following documentation is a layout for a standard date dimension to save you time, energy a vastly expand the tools needed for today’s modern database professional.

This calendar has both backward and forward looking dates ranging from the year 2000 thru to the end of the year 2029. For weekly conscious organizations, weeks start on Sundays and end on Saturdays with ‘Y’ flags to differentiate between weekdays and weekends. This calendar also includes statutory holidays to easily enable analytics across long weekends where retail users may want to highlight outliers or plan for additional labor requirements.

It doesn’t matter if you need an easy method to differentiate by day of the week or if you didn’t have a good model to track quarterly sales. The following DATE_DIM_VW contains almost every imaginable feature you could expect in a time calendar.

Viva Analytics!

Column Name Example - Formatting Description
Date YYYY-MM-DD Standard date field used for joins, format YYYY-MM-DD (join format option #1)
Day 1, 2, 3, 4... Numeric date of the month e.g. 1, 2, 3, 4 thru 30
DaySuffix 1st, 2nd, 3rd, 4th... Date suffix e.g. 'st' for the '1st' day of the month
Weekday 1, 2, 3, 4, 5, 6, 7 Numeric day of that week. e.g. 7 for the 7th day of the week which is Saturday
WeekDayName Sun, Mon, Tues... Weekday name for day of the week. e.g. Sun thru Sat
IsWeekend 1 Weekend day flags - e.g. 1 for either Saturday or Sunday
IsHoliday 1
Date is a statutory holiday - e.g. 1
HolidayText New Year's, Etc... Contains the name of the actual statutory holiday. e.g. Martin Luther King Day
DOWInMonth 1,2,3,4... Date of Week in the month. e.g. values 1 thru 52 for the dates 2001-01-01 thru 2000-01-07 has the value of 1 for each day of the first week of that year
DayOfYear 1,2,3,4.. Numeric Day of the year e.g. 1, 2, 3, 4 thru 365
WeekOfMonth 1,2,3,4,5 Numeric Week of the Month e.g. 1 thru 5 (depending on how many weeks there are in any given month
WeekOfYear 1,2,3,4... Numeric Week of the Year e.g. 1 thru 53 (depending on how many weeks there are in any given year)
ISOWeekOfYear 1,2,3,4... Numeric Week of the Year e.g. 1 thru 52 (depending on the year, there are either 364 or 371 days in the year)
Month 1, 2, 3, 4, 5, 6, 7, 8, 9,10 ,11, 12 Numeric Month of the Year e.g. 1 thru 12
MonthName Jan, Feb, Mar... Month Name - 3 characters - e.g. Jan thru Dec
Quarter 1, 2, 3, 4 Numeric Quarter of the Year e.g. 1 thru 4
QuarterName First, Second... Quarter Full Naming convention - e.g. First thru Fourth
QQ
Q1, Q2, Q3, Q4 Quarter short naming convention - Q1 thru Q4
QQYYYY 012019, 022019... Quarter and Year value as string - e.g. 012019
QQ_YYYY Q1-2019, Q2-2019...
Quarter and Year value with hyphen separator - e.g. Q1-2019
YYYYQQ 201901, 201902... Year and Quarter naming convention - e.g. 201901
YYYY_QQ 2019-Q1, 2019-Q2... Year and Quarter value with hyphen separator, starting with year - e.g. 2019-Q1
Year 2018, 2019, 2020... Year value as a numeric - e.g. 2019 (allows filtering on any year - for year-to-date reports the YTD column should be filtered)
MMYYYY 012019, 022019, 032019... Month and Year value as string - e.g. 042019
MM_YYYY 01-2019, 02-2019... Month and Year value with hyphen separator - e.g. 04-2019
YYYY_MM 2019-01,2019-02... Month and Year value with hyphen separator, starting with year - e.g. 2019-04
MonthYear Jan2019, Feb2019... Month and Year value with month alpha - e.g. Apr2019
Month_Year Jan-2019, Feb-2019... Month and Year value with hyphen separator and month alpha - e.g. Apr-2019
Year_Month_at 2019-Jan, 2019-Feb... Month and Year value with hyphen separator, starting with year and month alpha - e.g. 2019-Apr
YearMonth_at 2019Jan, 2019Feb... Month and Year value, starting with year and month alpha - e.g. 2019Apr
FirstDayOfWeek 2018-12-31, 2019-01-07... First calendar date of the week - e.g. 2019-04-07 (required for any weekly reporting where the first day of each week is Sunday)
LastDayOfWeek 2019-01-06, 2019-01-13... Last calendar date of the week - e.g. 2019-04-13 (required for any weekly reporting where the first day of each week is Sunday)
FirstDayOfMonth 2019-01-01, 2019-02-01... First calendar date of the month - e.g. 2019-04-01 (required for any monthly reporting where filtering is required to determine the start of the month)
LastDayOfMonth 2019-01-30, 2019-02-28... Last calendar date of the month - e.g. 2019-04-01 (required for any monthly reporting where filtering is required to determine the end of the month)
FirstDayOfQuarter 2019-01-01, 2019-04-01... First calendar date of the quarter - e.g. 2019-04-01
LastDayOfQuarter 2019-03-31,2019-06-30... Last calendar date of the quarter - e.g. 2019-06-30
FirstDayOfYear 2019-01-01, 2020-01-01... First calendar date of the year - e.g. 2019-01-01
LastDayOfYear 2019-12-31, 2020-12-31... Last calendar date of the year - e.g. 2019-12-31
FirstDayOfNextMonth 2019-01-01,2019-02-01... First calendar date of the next month from this date - e.g. today's date is 2019-04-06 and the first date of the next month is 2019-05-01
FirstDayOfNextYear 2020-01-01, 2021-01-01... First calendar date of the next year from this date - e.g. today's date is 2019-04-06 and the first date of the next year is 2020-01-01
SameDayLastYear 2018-01-01 Same calendar date from the prior year - e.g. today's date is 2019-04-06 and the same day last year is 2018-04-06. (Easily compare the current date sales to the same day last year)
CurrentDate Y Current date flag (is the real-time current date - filter 'Y' on this field to find only the current date e.g. 2019-04-06)
CurrentDateLYR Y Current date of the prior year flag (is the real-time current date - filter 'Y' on this field to find only the prior year date associated with the current date e.g. 2018-04-06)
CurrentWeek Y Current week flag (filter 'Y' on this field to find all dates associated with the current week e.g. 2019-04-07 thru 2019-04-13)
CurrentWeekLYR Y Current week flag last year (filter 'Y' on this field to find all dates associated with the current week last year e.g. 2018-04-07 thru 2018-04-13)
WTD_vs_WTD_LYR WTD, WTD_LYR Current Week-to-Date Flag (filter 'WTD' for days including start of the week thru current date and filter 'WTD_LYR' for same days of the week Last Year)
CurrentMonth Y Current month flag (filter 'Y' on this field to find all dates associated with the current month e.g. 2019-04-01 thru 2019-04-30)
CurrentMonthLYR Y Current month flag last year (filter 'Y' on this field to find all dates associated with the current month last year e.g. 2018-04-01 thru 2018-04-30)
MTD_vs_MTD_LYR MTD, MTD_LYR Current Month-to-Date Flag (filter 'MTD' for days including start of the month thru current date and filter 'MTD_LYR' for same days of the month last year)
CurrentQuarter Y Current quarter flag (filter 'Y' on this field to find all dates associated with the current quarter e.g. 2019-04-01 thru 2019-06-30)
CurrentQuarterLYR Y Current quarter flag last year (filter 'Y' on this field to find all dates associated with the current quarter last year e.g. 2018-04-01 thru 2018-06-30)
QTD_vs_QTD_LYR QTD, QTD_LYR Current Quarter-to-Date Flag (filter 'QTD' for days including start of the quarter thru current date and filter 'QTD_LYR' for same days of the quarter last year)
CurrentYear Y Current year flag (filter 'Y' on this field to find all dates associated with the current year e.g. 2019-01-01 thru 2019-12-31)
CurrentLYR Y Current year flag last year (filter 'Y' on this field to find all dates associated with the last year e.g. 2018-01-01 thru 2018-12-31)
YTD YTD Current Year-to-Date flag 'YTD' for flagging all dates up to the current date. e.g. 2019-01-01 thru Current Date (Does not include values past current date)
YTD_vs_LYR YTD, YTD_LYR Current Year-to-Date flag 'YTD' and 'YTD_LYR' for flagging all dates up to the current date and the same period of the prior year. e.g. 2018-01-01 thru Current Date of last year and 2019-01-01 thru Current Date (Does not include values past current date or the prior year or past the current date)
Style101 01/01/2019 SQL Server ANSI Date Standard format MM/DD/YYYY ( Alternate join template )
Style112 20190101
SQL Server ANSI Date Standard format YYYYMMDD ( Alternate join template )