6 Replies Latest reply: Oct 15, 2012 12:06 AM by jeneesh RSS

    function VS query

      I'wrote a function to get the first day of the week given a day in that week:
      I tested my queru in SQLDeveloper:
      Select Next_Day(To_Date(:day1,'dd-mm-yyyy')-7, 'Monday')
      from dual;

      Gives me 08-OCT-2012 as result: correct

      I'wrote this sample query in a function:

      function get_firstday (day1 date) return date
      begin_day date;
      select next_day(to_date(day1,'dd-mm-yyyy')-7, 'Monday')
      into begin_day
      from dual;
      return begin_day;

      When I use the function I get as result 10-OCT-2012

      Does anyone see the mistake I'm making?

      I've tried everything without success.

      Your suggestions are higly appreciated.