16.20 - Examples of Queries of Calendar Data - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantageā„¢ Data Dictionary

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
zzu1512081120577.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.ditaval

These examples show simple queries that you can use to determine the day of the week (day_of_week) and the date at the beginning of the week (weekBegin). The session calendars are the ISO and COMPATIBLE system-defined calendars.

  • The first two examples provide queries that return the day of the week (for example, day 1, 2, or 7) for a particular date.
  • The last two examples provide queries that return the date of the first day of a week (day 1) for the week to which a particular date belongs.

Example: Day of the Week (ISO Calendar)

Sel day_of_week from Sys_Calendar.Calendar where calendar_date = date '2011-01-01';
day_of_week
-----------
6

Example: Day of the Week (COMPATIBLE Calendar)

Sel day_of_week from Sys_Calendar.Calendar where calendar_date = date '2011-01-01';
day_of_week
-----------
1

Example: Beginning of the Week (ISO Calendar)

Sel weekBegin from Sys_Calendar.BusinessCalendar where calendar_date = date '2011-01-01';
WeekBegin
-----------
10/12/27

Example: Beginning of the Week (COMPATIBLE Calendar)

Sel weekBegin from Sys_Calendar.BusinessCalendar where calendar_date = date '2011-01-01';
WeekBegin
-----------
11/01/01