How to iterate over a date range in PL/SQL

declare
  start_date number;
  end_date number;
  business_date varchar2(20);
begin
  start_date := to_number(to_char(to_date(‘01.01.2004’, ‘DD.MM.RRRR’), ‘j’));
  end_date := to_number(to_char(to_date(‘31.12.2004’, ‘DD.MM.RRRR’), ‘j’));
  for cur_r in start_date..end_date loop
    business_date := to_char(to_date(cur_r, ‘j’), ‘DD.MM.RRRR’);
    dbms_output.put_line(business_date);
  end loop;
end;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: