Home » SQL & PL/SQL » SQL & PL/SQL » Help with SQL (
Help with SQL [message #409168] Fri, 19 June 2009 15:33 Go to next message
Messages: 1
Registered: June 2009
Junior Member

I have a requirment to write a procedure populate calendar table like, year, day, day of the week, month, month end date. I could able to find the queries for the above mentioned coulms. But I am not able to find a sql to identify the following columns. You will understand what am I asking for if you look at the column names. Please look at them and provide me the sql queries.

weekend (0-yes, 1-no),
announced holiday (0-yes, 1-no), (like x-mas, thanks giving..)
fiscal year quarter time span,
fiscal year quarter end date
year time span,
fiscal year_time_span,
fiscal year_end_date

Please make sure I need to add these sql's in my cursor and loop
based on the dates I give. lets say I want to populate the data
for 1 year, I need to get 365 records and date value starts from
'01-jan-2009' to '31-dec-2009'. for every 3 months we needs to
calculate the quarter number, remaining days for the quarter. lets say today is 19 Jun, 2009 its a 2nd quearter. We have to calculate the remainig days (11 days). The date value would become 20 Jun, 2009 when it loops then the remaning days in this quarter should be (10 days). Please help me.


[Updated on: Fri, 19 June 2009 15:49]

Report message to a moderator

Re: Help with SQL [message #409174 is a reply to message #409168] Fri, 19 June 2009 17:02 Go to previous messageGo to next message
Messages: 3186
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
I have worked at a couple of different companies so far, and most of them had different definitions of what those things actually meant.

Where I work now, even inside the same company the definition of "holiday" and "weekend" is different in different locations.

So step one would be to get the definition of those things out of the people in charge.
Re: Help with SQL [message #409191 is a reply to message #409168] Sat, 20 June 2009 01:48 Go to previous message
Michel Cadot
Messages: 63929
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
TO_CHAR function and Datetime format elements section will help (note the 'Q' and 'D' ones, for instance, for quarter and day in week, so week-end day).

LAST_DAY function will give you the last day of the month.


[Updated on: Sat, 20 June 2009 01:48]

Report message to a moderator

Previous Topic: Need to generate unique number for the combination of values (merged)
Next Topic: how to separate mobileno and landlineno in oracle(input is in single field)
Goto Forum:

Current Time: Wed Oct 26 16:27:12 CDT 2016

Total time taken to generate the page: 0.08510 seconds