## DATE_JOUR_HEURE

Doc
Details
Grants
References
Dependencies
Code

TEXT
    FUNCTION          "DATE_JOUR_HEURE" (annee IN NUMBER,noSemaine IN NUMBER,noJour IN NUMBER, heure in varchar2)
    RETURN DATE IS
    -- Pour lundi noJour est égal à 1
    -- noSemaine correspon à la numérotation internationale

    dateDepart VARCHAR2 (10);
    res DATE;
    vjour VARCHAR2(10);
    vheure number;
    vminute number;

    BEGIN
    vheure := substr(heure,1,2);
    vminute := substr(heure,4,2);

    if vminute < 0 then
      vminute := vminute + 60;
      vheure := vheure - 1;
    end if;

    dateDepart := '31/12/' || to_char(annee-1);
    SELECT NEXT_DAY(to_date(dateDepart,'DD/MM/YYYY'),1) +
        (noSemaine - 1) * 7 + noJour -1 INTO res FROM dual;

    res := to_date(to_char(res) || ' ' || vheure || ':' || vminute|| ':00','DD/MM/YYYY HH24:MI:SS');
    --dbms_output.put_line(res||' - '||vheure|| ' - ' || vminute );
    RETURN res;
    END date_jour_heure;