Skip to content

Instantly share code, notes, and snippets.

@makanimason
Created June 27, 2011 19:40
Show Gist options
  • Save makanimason/1049635 to your computer and use it in GitHub Desktop.
Save makanimason/1049635 to your computer and use it in GitHub Desktop.
simple Oracle 11 stored function
CREATE OR REPLACE FUNCTION weekStartingFriday(dayval IN DATE)
RETURN DATE IS
adjustment NUMBER;
BEGIN
adjustment := TO_NUMBER(TO_CHAR(dayval, 'D'));
IF (adjustment >= 6) THEN
adjustment := adjustment - 6;
ELSE
adjustment := adjustment + 1;
END IF;
RETURN(dayval - adjustment);
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment