如上所述,我需要从日历视图中计算ISO年份, 我也创建了一个用于计算ISO周数的视图,但我无法弄清楚计算ISO年的逻辑,有人可以尽快发布。
提前致谢。 kishor
日历视图的结构
REPLACE VIEW Sys_Calendar.CALENDAR(
CALENDAR_DATE, DAY_OF_WEEK, DAY_OF_MONTH, DAY_OF_YEAR, day_of_calendar, weekday_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) 如 SEL 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;
答案 0 :(得分:0)
如果您使用的是相当现代的Teradata版本,则可以使用TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR(calendar_date,'ISO')
如果以2014-12-31为例,其ISO周为1.此功能将相应返回2015年的ISO年份。