从公历年和其他字段计算 ISO 年的逻辑
logic for calculating ISO year from gregorian year and other fields
如上所述,我需要从日历视图中计算 ISO 年份,
我还在上面创建了一个视图来计算 ISO 周数,但我无法弄清楚计算 ISO 年的逻辑,有人可以尽快 post 它吗?
提前致谢。
基绍尔
日历视图的结构
REPLACE VIEW Sys_Calendar.CALENDAR(
calendar_date,
day_of_week,
day_of_month,
day_of_year,
day_of_calendar,
周day_of_month,
week_of_month,
week_of_year,
week_of_calendar,
month_of_quarter,
month_of_year,
month_of_calendar,
quarter_of_year,
quarter_of_calendar,
year_of_calendar)
作为
选择
calendar_date,
DayNumber_Of_Week(calendar_date),
DayNumber_Of_Month(calendar_date),
DayNumber_Of_Year(calendar_date),
DayNumber_Of_Calendar(calendar_date),
DayOccurrence_Of_Month(calendar_date),
WeekNumber_Of_Month(calendar_date),
WeekNumber_Of_Year(calendar_date),
WeekNumber_Of_Calendar(calendar_date),
MonthNumber_Of_Quarter(calendar_date),
MonthNumber_Of_Year(calendar_date),
month_of_calendar,
QuarterNumber_Of_Year(calendar_date),
quarter_of_calendar,
YearNumber_Of_Calendar(calendar_date)
从 Sys_Calendar.CALENDARTMP;
如果您使用的是相当现代的 Teradata 版本,则可以使用 TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR(calendar_date,'ISO')
如果我们以2014-12-31为例,它的ISO周是1。这个函数将对应return2015年作为它的ISO年
如上所述,我需要从日历视图中计算 ISO 年份, 我还在上面创建了一个视图来计算 ISO 周数,但我无法弄清楚计算 ISO 年的逻辑,有人可以尽快 post 它吗?
提前致谢。 基绍尔
日历视图的结构
REPLACE VIEW Sys_Calendar.CALENDAR(
calendar_date, day_of_week, day_of_month, day_of_year, day_of_calendar, 周day_of_month, week_of_month, week_of_year, week_of_calendar, month_of_quarter, month_of_year, month_of_calendar, quarter_of_year, quarter_of_calendar, year_of_calendar) 作为 选择 calendar_date, DayNumber_Of_Week(calendar_date), DayNumber_Of_Month(calendar_date), DayNumber_Of_Year(calendar_date), DayNumber_Of_Calendar(calendar_date), DayOccurrence_Of_Month(calendar_date), WeekNumber_Of_Month(calendar_date), WeekNumber_Of_Year(calendar_date), WeekNumber_Of_Calendar(calendar_date), MonthNumber_Of_Quarter(calendar_date), MonthNumber_Of_Year(calendar_date), month_of_calendar, QuarterNumber_Of_Year(calendar_date), quarter_of_calendar, YearNumber_Of_Calendar(calendar_date) 从 Sys_Calendar.CALENDARTMP;
如果您使用的是相当现代的 Teradata 版本,则可以使用 TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR(calendar_date,'ISO')
如果我们以2014-12-31为例,它的ISO周是1。这个函数将对应return2015年作为它的ISO年