pl-sql – Consider the final term until the following day at 03:00 in the morning using PLSQL

Question:

Guys, I need to do the following validation:
When a registration enters my database, I need to validate the effective date of this registration. If the term is between the current date then the registration is valid.
Ex:
Effective from 12/03/2015 to 13/03/2015, the term ends on 13/03/2015 correct?
But I need to consider the end date until 03/14/2015 at 03:00 am, after this time the end date will no longer be valid.
Does anyone have any idea how I can create this rule?

Answer:

Something like

CREATE OR REPLACE TRIGGER TRG_TABELA
  BEFORE
    INSERT OR
    UPDATE 
  ON TABELA
BEGIN
  /*3 horas de "hoje" até 3 horas de "amanhã"*/
  IF NOT (DATA BETWEEN (TRUNC(SYSDATE) + 3/24) AND TRUNC(SYSDATE+1) + 3/24)) THEN
    RAISE_APPLICATION_ERROR(-20001,'DATA INVÁLIDA PARA PERÍODO');
  END IF;
END;
/
Scroll to Top