Solved

Calendar function in Oracle

Posted on 2001-08-29
5
959 Views
Last Modified: 2007-12-19
Hi,

I am currently using oracle 8.0.5 to create web application for the production users. The problem that I face here is the application do not have working calendar which consists of our company holidays. Do Oracle itself provide any buid in calendar function that can be modified accordingly to different working calendar? Your advice is highly appreciated.

Thanks,
Chewlf
0
Comment
Question by:chewlf
5 Comments
 

Expert Comment

by:raghav3
Comment Utility
Hi chewlf,
        The calender can be designed using the Forms and to be used/modified according to the company requirement.
Your application can use the designed calender which would be similar to any calender available.
        What front end u are using pls let me know so that i can suggest the suitable solution.
        U can also use the Date() function and Dynamic Sql to deal with the problem



Thanks,
Raghav
0
 
LVL 6

Accepted Solution

by:
Jankovsky earned 50 total points
Comment Utility
Hi,
Oracle doesn't have working calendar functions.
You should ctrate table for working days specification and create own stored procedures.
We usualy use:
Create table WD(YEAR Varchar2(4) PRIMATY KEY ,MASK Varchar2(366));
Each character in MASK can be 'Y' for working day and 'N' for holiday.

function is_holiday (aDt Date) return Boolean is
  vYEAR Varchar2(4):=To_char(aDT,'YYYY');
  vDay  Integer:=To_number(To_char(aDT,'DDD'));
  vMask Varchar2(366);
Begin
  Select Mask into vMask from WD where YEAR=aYEAR;
  return(Sunstr(vMask,vDay,1)='N');
End is_holiday;

function Workingdays (aDt1 Date,aDt2 Date) return Number is
  vYEAR1 Varchar2(4):=To_char(aDT1,'YYYY');
  vDay1  Integer:=To_number(To_char(aDT1,'DDD'));
  vYEAR2 Varchar2(4):=To_char(aDT2,'YYYY');
  vDay2  Integer:=To_number(To_char(aDT2,'DDD'));
  vd1    Integer;
  vd2    Integer;
  vS     Varchar2(366);
  vCnt   Number:=0;
Begin
  for r1 in (Select YAER,MASK from WD where YEAR between
             aYEAR1 and aYEAR2 order by YEAR) LOOP
    if r1.YEAR=vYEAR1 then
      d1:=vDay1;
    else  
      d1:=1;
    end if;
    if r1.YEAR=vYEAR2 then
      d2:=vDay2;
    else  
      d2:=366;
    end if;
    vS:=Replace(Substr(r1.MASK,d1,d2),'N');
    vCnt:=vCnt+Length(vS);
  end LOOP;
  return vCnt;
End is_holiday;

There is quiet a lot of possibilities how do it.

Regards

0
 

Author Comment

by:chewlf
Comment Utility
I am using HTML to display the application in IE.

You have a good suggestion, Jankovsky. I will try it out. Thanks.

Anybody know how to use owa_util.calendarprint? I think this maybe the another alternative to do it. I am trying to find any Oracle build in function that do not need to create any table form.

thanks and regards,
chewlf
0
 
LVL 6

Expert Comment

by:Mindphaser
Comment Utility
Please update and finalize this old, open question. Please:

1) Award points ... if you need Moderator assistance to split points, comment here with details please or advise us in Community Support with a zero point question and this question link.
2) Ask us to delete it if it has no value to you or others
3) Ask for a refund so that we can move it to our PAQ at zero points if it did not help you but may help others.

EXPERT INPUT WITH CLOSING RECOMMENDATIONS IS APPRECIATED IF ASKER DOES NOT RESPOND.

Thanks,

** Mindphaser - Community Support Moderator **

P.S.  Click your Member Profile, choose View Question History to go through all your open and locked questions to update them.
0
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
Recommended disposition:

    Accept Jankovsky's comment(s) as an answer.

DanRollins -- EE database cleanup volunteer
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now