Examples: Queries of Calendar Data - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905
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 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 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
-----------
2010/12/27

Example: Beginning of the Week (COMPATIBLE Calendar)

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