Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Bonjour tout le monde
SUB MasterCalendarIn(D,Table) // début de la routine
TRACE La table RESIDENT contenant le champ date $(D) se nomme $(Table);
// Calcul du minimum et du maximum
[Temp]:
LOAD
MIN([$(D)]) AS StartDate,
MAX([$(D)]) AS EndDate
RESIDENT [$(Table)];
// Récupération du Min et du Max
LET vStartDate = Num(Peek('StartDate', 0, 'Temp'));
LET vEndDate = Num(Peek('EndDate' , 0, 'Temp'));
// Listing en continue de toutes les dates dans l'intervalle
[TempCalendar]:
LOAD
DATE($(vStartDate) + RowNO() - 1) AS TempDate
AutoGenerate
$(vEndDate) - $(vStartDate) + 1;
QUALIFY*;
UNQUALIFY [$(D)]; // clé isolé
// Création du MasterCalendar
[Calendar.$(D)]:
LOAD
TempDate AS [$(D)],
Week(TempDate) AS Week,
YEAR(TempDate) AS Year,
Month(TempDate) AS Month,
WEEKDAY(TempDate) AS Weekday,
Dual('Q' & CEIL(Month(TempDate)/3), CEIL(Month(TempDate)/3)) AS Quater
RESIDENT [TempCalendar] ;
UNQUALIFY*;
// Suppression tables temporaires
DROP TABLES
[Temp],
[TempCalendar];
END SUB // fin de la routine
// Utilisation de la routine
CALL MasterCalendarIn('Date','Fait');