Database Administration (MOSC)

MOSC Banner

Unable to get 1st day of month

edited Nov 23, 2011 1:54AM in Database Administration (MOSC) 2 comments
I've to write a procedure to generate dynamic "values less than date" for adding new partitons to lot of tables but it doesn't generate 1st day of next month. I'm able to get the last day but when I try to add 1 day more it error out. Any idea?

This works fine.

  1  set serveroutput on SIZE 1000000
  2  set lines 150
  3  declare
  4     start_date date := last_day(to_date('01-JAN-2012','DD-MON-YYYY')) ;
  5  begin
  6     for ctr in 1 .. 12                     
  7     loop
  8             dbms_output.put_line('date less than '|| last_day(add_months(start_date,ctr-1)) || ' '|| to_char(last_day(add_months(start_date,ctr-1)),'MONYYYY')) ;

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center