//$(Include=..\..\qvdata\holiday script.qvs);
//------------------------------------------------------------------------------------------
// Date range
//------------------------------------------------------------------------------------------
//Let zFrom = Num(YearStart(AddYears(Today(1), -1)));
//Let zTo = Num(Floor(YearEnd(Today(1) + 30)));
Let zFrom = Num(Date(Date#('2006/07/01')));
Let zTo = Num(Date(Date#('2009/06/30')));
//Let zTo = Num(Today(1));
//------------------------------------------------------------------------------------------
// Fiscal year parameters
//------------------------------------------------------------------------------------------
Set zGLYearStartMonth = 7; // Financial year start month (1 = same As cal year start)
Set zLastDOM = 31; // Last day of financial month (31 = end of cal month)
//Set zFutureFinYearsToGenerate = 1;
//------------------------------------------------------------------------------------------
// Current date parameters
//------------------------------------------------------------------------------------------
Let zToday = Today(1);
Let zCurrentYear = Year(Today(1)); // Year value
Let vCurrentGLYear = zCurrentYear + If (zGLYearStartMonth = 1 Or Month(Today(1)) < zGLYearStartMonth, 0, 1);
Let vHolidayList = If(Len(vHolidayList) > 0, vHolidayList, '0');
Let vBaseSeq = Year(zStartDate) * 12 + Month(zStartDate) - 1;
//LET zTo = MakeDate($(vCurrentGLYear) + $(zFutureFinYearsToGenerate), $(zGLYearStartMonth)) - 1;
tmpCalendar:
LOAD
Date($(zTo) - RowNo() +1 ) As CalDate
AutoGenerate($(zTo) +1 - $(zFrom));
Calendar:
LOAD *,
if(IsNull(Peek('YYYYWW')), 1, if(YYYYWW = Peek('YYYYWW'), Peek('WeekSeq'), Peek('WeekSeq') + 1)) as WeekSeqx,
// If date is a Monday, start a new week:
if(IsNull(Peek('WeekSeq')), 1, if (WeekDay(CalDate) = 0, Peek('WeekSeq') + 1, Peek('WeekSeq'))) as WeekSeq,
WeekEnd(Date) as [Week Name],
Left(YYYYMM,4)&'M'&Right(YYYYMM,2) as ProphixDate
;
LOAD CalDate As Date,
CalDate As [Ship Date],
CalMonth As Month,
CalYear As Year,
CalDay As Day,
*,
YearMonth as YYYYMM,
(WeekStart(CalDate) - FirstMondayOfYear) / 7 + If(tmpWDYear = 0, 1, 2) As Week, //YearWeek,
Left(YearMonth,4)& Right('0' & ((WeekStart(CalDate) - FirstMondayOfYear) / 7 + If(tmpWDYear = 0, 1, 2)), 2) as YYYYWW,
Left(YearMonth,4)& Right('0' & Week(CalDate), 2) as YYYYWW2,
((WeekStart(CalDate) - FirstMondayOfMonth) / 7 + 2) As MonthWeek,
CalYear & ' ' & Quarter as YearQuarter,
if(IsNull(Peek('YearMonth')), 1, if(YearMonth = Peek('YearMonth'), Peek(Seq), Peek('Seq') + 1)) as Seq
;
LOAD *,
Date(MakeDate(CalYear, 1, 😎 - If(tmpWDYear = 0, 7, tmpWDYear)) As FirstMondayOfYear,
Date(MakeDate(CalYear, CalMonth, 😎 - If(tmpWDMonth = 0, 0, tmpWDMonth)) As FirstMondayOfMonth,
If(WorkingDay, WorkDay, 0) As WorkDay2,
GLYear * 100 + GLPeriodM As GLPeriod,
Dual(Text(Date(CalDate, 'YYYYMM')), MonthSeq) As Period,
Dual('Q' & Ceil(CalMonth / 3), Ceil(CalMonth / 3)) As Quarter,
CalYear * 100 + CalMonth as YearMonth
;
LOAD *,
(CalYear - Year($(zFrom)))*12 + (CalMonth - month($(zFrom))) + 1 As MonthSeq,
CalDate - YearStart(CalDate) As DayOfYear,
RangeMax(1, NetWorkDays(YearStart(CalDate), CalDate, $(vHolidayList))) As WorkDayOfYear,
NetWorkDays(YearStart(CalDate), YearEnd(CalDate), $(vHolidayList)) As YearWorkDays,
Date(Floor(MonthStart(CalDate))) As MonthStart,
Date(Floor(MonthEnd(CalDate))) As MonthEnd,
If(Mod(CalYear, 100) = 0 And Mod(CalYear, 400) <> 0, 1, 0) As LeapYear,
If(Match(WeekDay, 'Sat', 'Sun') Or Match(CalDate, $(vHolidayList)), 0, 1) As WorkingDay,
If(Match(WeekDay, 'Sat', 'Sun'), 'Weekend', If(Match(CalDate, $(vHolidayList)), 'Holiday', 'Workday')) As DayType,
Num(WeekDay(MakeDate(CalYear, 1, 1))) As tmpWDYear,
Num(WeekDay(MakeDate(CalYear, CalMonth, 1))) As tmpWDMonth,
CalYear - $(zCurrentYear) As YearOffset,
// Fiscal year fields - GL Year
CalYear + If($(zGLYearStartMonth) <= 1 Or CalMonth < $(zGLYearStartMonth), 0, 1) As GLYear,
// Fiscal year fields - GL Period
If (CalMonth >= $(zGLYearStartMonth),
If(CalDay > $(zLastDOM), CalMonth - $(zGLYearStartMonth) + 2, CalMonth - $(zGLYearStartMonth) + 1),
If(CalDay > $(zLastDOM), CalMonth + (12 - $(zGLYearStartMonth) + 2), CalMonth + (12 - $(zGLYearStartMonth) + 1))) As GLPeriodM,
// Fiscal year fields - GLYearOffset
If (CalMonth < $(zGLYearStartMonth),
CalYear,
CalYear + 1) - $(vCurrentGLYear) As GLYearOffset
;
LOAD CalDate,
Day(CalDate) As CalDay,
Month(CalDate) As CalMonth,
Year(CalDate) As CalYear,
WeekDay(CalDate) As WeekDay,
RangeMax(1, NetWorkDays(MonthStart(CalDate), CalDate, $(vHolidayList))) As WorkDay,
NetWorkDays(MonthStart(CalDate), MonthEnd(CalDate), $(vHolidayList)) As MonthWorkDays,
NetWorkDays(CalDate, MonthEnd(CalDate), $(vHolidayList)) As WorkDaysToMonthEnd,
Date(MonthStart(CalDate), 'MMMM YYYY') As MonthYear,
Date(MonthStart(CalDate), 'MMM YY') As MonthYearShort
Resident tmpCalendar
Order By CalDate;
// Keep CalDate As an indicator that the date is included in the calendar
Drop Fields tmpWDYear,
tmpWDMonth,
CalMonth,
CalYear,
CalDay;
Drop Table tmpCalendar;
Store Calendar into CalendarBraam.qvd;
how can I add the 2nd fiscal month and year to this calendar