to find the first day of the month [message #371839] |
Tue, 12 December 2000 14:04 |
kusuma
Messages: 5 Registered: December 2000 Location: India
|
Junior Member |
|
|
Hi,
I need to print a report for the present month.
The report is printed at the end of the month. I need to select the records ranging from start of the month to end of the month. What is the query to be written to fetch the records.
appreciate your help
kusuma
|
|
|
Re: to find the first day of the month [message #371843 is a reply to message #371839] |
Wed, 13 December 2000 02:41 |
John R
Messages: 156 Registered: March 2000
|
Senior Member |
|
|
Assuming the query will be run after the end of the month (ie be run for the previous month), it could be done as:
DECLARE
l_last_month_start DATE:= TRUNC(Add_months(sysdate,-1),'MON');
l_last_month_end DATE:= TRUNC(sysdate,'MON');
CURSOR c_records(l_start_date DATE,l_end_date DATE)
SELECT some_fields
FROM some_table
WHERE date_field> l_start_date
AND date_field< l_end_date;
BEGIN
FOR rec IN c_records LOOP
report code in here;
END LOOP;
END;
|
|
|