2015-08-19 35 views
0

如上所述,我需要從日曆視圖中計算ISO年, 我還創建了一個用於計算ISO週數的視圖,但我無法計算出數字爲了計算ISO年份的邏輯,有人可以儘快發佈。用於計算來自公曆年和其他字段的ISO年的邏輯

在此先感謝。 基肖爾

日曆視圖的結構

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) AS 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_Y ear(calendar_date), quarter_of_calendar, YearNumber_Of_Calendar(calendar_date) FROM Sys_Calendar.CALENDARTMP;

回答

0

如果你在一個相當現代版的Teradata的,你可以使用TD_SYSFNLIB.YEARNUMBER_OF_CALENDAR(calendar_date,'ISO')

如果我們把作爲2014-12-31爲例,它的ISO周爲1。該功能會相應地返回2015年,因爲它是ISO年。

+0

非常感謝安德魯,這工作。 –

+0

僅供我使用的其他信息14.10.01.07 TD版本 –