新建表粘贴如下代码,即可生成一张日期表(代码非原创,做了简单的修改,汉字是我加的)
dateT =
VAR WeekNumberFlag = 2
// 1 - sunday , 2 - monday // 1 - Sunday (1) and ends on Saturday (7). numbered 1 through 7.
// 2 - Monday (1) and ends on Sunday (7). // 3 - Monday (0) and ends on Sunday (6).numbered 1 through 7
VAR WeekDayFlag = 2 VAR CalendarYearStart = 2016 VAR CalendarYearEnd =2020
---------------------------------------------------------------------------------------------------------
VAR CalendarBase = CALENDAR( DATE( CalendarYearStart , 1 , 1 ) , DATE( CalendarYearEnd , 12 , 31) )
RETURN
GENERATE (
CalendarBase,
VAR CalendarCurrentDate = [Date]
VAR CalendarYear = YEAR ( CalendarCurrentDate )
VAR CalendarMonth = MONTH ( CalendarCurrentDate )
VAR CalendarQuarter = SWITCH( TRUE() ,
CalendarMonth <= 3 , 1 ,
CalendarMonth <= 6 , 2 ,
CalendarMonth <= 9 , 3 ,4)
VAR CalendarYearMonth = CalendarYear * 100 + CalendarMonth
VAR CalendarYearWeek = CalendarYear * 100 + WEEKNUM( CalendarCurrentDate )
VAR CalendarDayOfWeek = WEEKDAY( CalendarCurrentDate , WeekDayFlag )
VAR CalendarWeekOfYear = WEEKNUM( CalendarCurrentDate , WeekNumberFlag )
VAR CalendarDayOfMonth = DAY( CalendarCurrentDate )
RETURN ROW (
"年度" , CalendarYear ,
"季度" , CalendarQuarter ,
"月份" , CalendarMonth ,
"周度" , CalendarWeekOfYear ,
"日" , CalendarDayOfMonth ,
"日期" , CalendarCurrentDate ,
"DayOfWeek" , CalendarDayOfWeek ,
"DayOfWeekName" , FORMAT( CalendarCurrentDate , "aaaa" ) ,
"YearName" , "Y" & CalendarYear ,
"QuarterName" , "Q" & CalendarQuarter ,
"MonthName", FORMAT ( CalendarCurrentDate, "mmm" ) ,
"WeekName", "W" & CalendarWeekOfYear ,
"YearQuarter", CalendarYear * 100 + CalendarQuarter ,
"YearMonth" , CalendarYearMonth ,
"YearWeek" , CalendarYear * 100 + CalendarWeekOfYear ,
"DateCode" , CalendarYear * 10000 + CalendarMonth * 100 + CalendarDayOfMonth
)
)