Geeks Talk

Prepare for your Next Interview




pl/sql

This is a discussion on pl/sql within the SQL forums, part of the Databases category; write a program to accept a year and display all sundays along with the date....


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-06-2008
Junior Member
 
Join Date: Aug 2008
Location: hyderabad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
ipsita_verma is on a distinguished road
pl/sql

write a program to accept a year and display all sundays along with the date.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-09-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: pl/sql

Create or replace procedure test_proc ( year number ) is

lastday_prev_year date;
first_sunday date;
i number;
begin
lastday_prev_year:= '31-dec-'||to_char(year-1);
select next_day(lastday_prev_year,'sunday') into first_sunday from dual;
for i in 1..52
loop
dbms_output.put_line(first_sunday|| ' is sunday');
first_sunday := first_sunday + 7;
end loop;
end ;
/

Last edited by krishnaindia2007 : 08-09-2008 at 08:26 AM.
Reply With Quote
  #3 (permalink)  
Old 08-30-2008
Junior Member
 
Join Date: Aug 2008
Location: KOLKATA
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
rajivgupta780184 is on a distinguished road
Smile Re: pl/sql

in this query you have to enter the year 4 times(e.g 08) in yy format.....!

======================================================
SELECT * FROM
(SELECT
(TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy') + rownum-1 ) date_list,
TRIM(to_char((TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy') + rownum-1 ),'DAY')) DAY_LIST
FROM all_objects
WHERE rownum <= TO_DATE ('31-dec-'||&ENTER_YY_FORMAT, 'dd-mon-yy') -
TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy')+1)TOT_DATE
WHERE TOT_DATE.DAY_LIST ='SUNDAY';

================================================

hope this will work for you...

THANKS
RAJIV GUPTA
YOGIK TECHNOLOGIES PVT. LTD.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes



All times are GMT -4. The time now is 07:30 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved