Mandag i en given uge for et bestemt år kan du få af følgende funktion (bemærk at årstallet skal skrives med fire cifre):
FUNCTION monday (week_no PLS_INTEGER, year CHAR) RETURN DATE IS jan_1_week PLS_INTEGER; jan_1_day PLS_INTEGER; nof_monday PLS_INTEGER; monday_in_week_no PLS_INTEGER; BEGIN -- The \"nof_monday\" is only there to make the procedure independent of the nls_territory setting SELECT TO_CHAR(TO_DATE(\'0101\'||year, \'DDMMYYYY\'), \'IW\'), TO_CHAR(TO_DATE(\'0101\'||year, \'DDMMYYYY\'), \'D\'), TO_CHAR(TO_DATE(\'01012001\', \'DDMMYYYY\'), \'D\') INTO jan_1_week, jan_1_day, nof_monday FROM sys.dual; IF jan_1_week>=52 THEN jan_1_week:=0; END IF; monday_in_week_no:=(week_no-jan_1_week-1)*7+(8-jan_1_day)+1+(nof_monday-1); RETURN TO_DATE(LPAD(monday_in_week_no, 3, \'0\') || year, \'DDDYYYY\'); END;
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.