Calculation of hours - weekends already excluded and how to exclude a vacation?
CREATE OR REPLACE FUNCTION | working_hours | ||||
( | in_start_dt | IN | DATE | DEFAULT SYSDATE | |
, | in_end_dt | IN | DATE | DEFAULT | SYSDATE |
)
RETURN | NUMBER |
DETERMINISTIC
IS
-- | ************************************* | |
-- | ** | ** |
-- | * b u s i n e s s __ h o u s *. | |
-- | ** | ** |
-- | ************************************* |
-- | working_hours returns the number of work houts (08:00-20:00) | |||
-- | Monday to Friday) between in_start_dt and in_end_dt. | |||
-- | If in_start_dt > in_end_dt, the results will be < = 0. | |||
-- | Holidays are not considered. | |||
d | NUMBER; | -Start_dt hours or end_dt after midnight | ||
end_dt | DATE | : = GREATEST (in_start_dt, in_end_dt); -In the case of dates were in disarray | ||
return_val | NUMBER; | -The number of hours of work | ||
start_dt | DATE | : = LEAST | (in_start_dt, in_end_dt); -In the case of dates were in disarray |
holiday_cnt NUMBER;
BEGIN
WITH | all_days | AS | |
( | |||
SELECT | start_dt + LEVEL - 1 | AS a_dt | |
Of | Double | ||
CONNECTION OF LEVEL < = 1 + TRUNC (end_dt) - TRUNC (start_dt) | |||
LESS | |||
SELECT trunc (calendar_day) | |||
Of | public_holiday | ||
) | |||
SELECT | SUM (12) | ||
IN | return_val | ||
Of | all_days | ||
WHERE | To_char (a_dt | ||
, "Dy". | |||
, ' NLS_DATE_LANGUAGE = "ENGLISH"' | |||
) | NOT IN ('Friday', 'Saturday'); | ||
-Adjust the hours of start_dt, if necessary | |||
IF TO_CHAR (start_dt | |||
, "Dy". | |||
, ' NLS_DATE_LANGUAGE = "ENGLISH"' | |||
) NOT IN ('Friday', 'Saturday') |
THEN
SELECT COUNT (*) | |||||
IN | holiday_cnt | ||||
Of | public_holiday | ||||
WHERE | TRUNC (Calendar_Day) between TRUNC (start_dt) and TRUNC (end_dt); | ||||
IF holiday_cnt > 0 | |||||
THEN | |||||
d: = 24 * (start_dt - TRUNC (start_dt)); | |||||
IF d > = 20 | |||||
THEN | -Do not count start_dt himself | ||||
return_val: = return_val - 12; | |||||
ELSIF > 8 d | |||||
THEN | -Do not count part of the start_dt | ||||
return_val: = return_val - (d - 8); | |||||
END IF; | |||||
END IF; |
END IF;
-Adjust the hours of end_dt, if necessary | ||
IF TO_CHAR (end_dt | ||
, "Dy". | ||
, ' NLS_DATE_LANGUAGE = "ENGLISH"' | ||
) NOT IN ('Friday', 'Saturday') | ||
THEN | ||
d: = 24 * (end_dt - TRUNC (end_dt)); | ||
IF d < = 8 | ||
THEN | -Do not count end_dt himself | |
return_val: = return_val - 12; | ||
ELSIF d < 20 | ||
THEN | -Do not count part of the end_dt | |
return_val: = return_val - (20 - d); | ||
END IF; | ||
END IF; |
IF in_start_dt > in_end_dt | |
THEN | |
return_val: = - return_val; | |
END IF; |
RETURN | return_val; | |
END | working_hours |
;
Select holiday h_day
H_DAY |
---|
30/12/2015 |
28/10/2015 |
25/08/2015 |
08/12/2015 |
create or replace function business_hours (p_start_timestamp in p_end_timestamp in timestamp, timestamp)
Return number
is
number of l_start_bh: = 8;
number of l_end_bh: = 20;
number of result;
Start
Select business_hrs
as a result
of (with
business_hours (start_dt, end_dt, daily_bh, Step) as
(select least (dr.start_dt, dr.end_dt), (dr.start_dt, dr.end_dt), greatest)
-case when to_char (least (dr.start_dt, dr.end_dt), 'dy') in ("Fri", "sat")
then-1
When the h.h_day is not null
then-2
on the other case when least (greatest (dr.start_dt, dr.end_dt),
trunc (least (Dr.start_dt, Dr.end_dt)) + l_end_bh / 24
) -
Greatest (least(Dr.start_dt,Dr.end_dt), trunc (least (Dr.start_dt, Dr.end_dt)) + l_start_bh / 24) > = 0
then least (greatest (dr.start_dt, dr.end_dt),
trunc (least (Dr.start_dt, Dr.end_dt)) + l_end_bh / 24
) -
Greatest (least(Dr.start_dt,Dr.end_dt), trunc (least (Dr.start_dt, Dr.end_dt)) + l_start_bh / 24)
0 otherwise
end
end daily_bh
1
from (select cast (p_start_timestamp as date) start_dt,)
Cast (p_end_timestamp as date) end_dt
of the double
) dr
left outer join
Holiday:
We h.h_day = trunc (least (start_dt, end_dt))
Union of all the
Select start_dt, end_dt,.
-case when to_char (trunc (start_dt) + No, "dy") in ("Fri", "sat")
then-1
When (select h_day vacation where h_day = trunc (start_dt) + not) is not null
then-2
on the other case when trunc (start_dt) + no<>
then (l_end_bh - l_start_bh) / 24
to another least (end_dt, trunc (end_dt) + l_end_bh / 24)-(trunc (end_dt) + l_start_bh / 24)
end
end,
Step + 1
of business_hours
where not<= trunc(end_dt)="" -="">=>
)
Select start_dt to_char (min (start_dt), 'dd.mm.yyyy hh24:mi:ss'),
end_dt to_char (max (end_dt), 'dd.mm.yyyy hh24:mi:ss'),
Sum (ceil (Greatest(0,daily_bh) / (1 / 24 / 60))) business_hrs
of business_hours
);
return the result;
end;
Select business_hours (to_timestamp ('10:20:30.123456 2015-12-01', 'yyyy-mm-dd hh24:mi:ss.ff'),)
TO_TIMESTAMP ('16:40:50.654321 2015-12-31', 'yyyy-mm-dd hh24:mi:ss.ff')
) minutes
of the double
MINUTES |
---|
14781 |
Concerning
Etbin
Tags: Database
Similar Questions
-
Just below the toolbar, Firefox tells me "download the latest applications"-what is and how can I stop it. It worked for 2 hours.
This has happened
Each time Firefox opened
== I opened Firefox "Add-ons" window
Disable or uninstall the toolbar MSN/Bing.
See this thread and disable or remove modules. -
I want to try Ubunta as my operating system. Someone has already tried this and how is it?
If you want to try, there are various options partitions for you. One is to download the files and bvurn on a CD. Boot from the CD and choose to run Ubuntu from the CD. This method does not offer a realistic experience, but it allows you to try the look-and-feel.
Alternatively, you can install the virtualization software (Sun Virtual Box, for example) and install Ubuntu to.
Download files and check options here:
http://www.Ubuntu.com/download/Ubuntu/download
Do a Bing or Google search on 'install Ubuntu after Windows' for other information, including tutorials.
Tim Ferguson
-
A few keys on my laptop stop working again. It's already happened and I do not remember how I fixed it
Hi cagoehring,
1. did you of recent changes on the computer?
2. What is the number of brand and model of the laptop?
I suggest to use the external keyboard and check if all the keys are working properly.
Also use the keyboard on the screen and check if it works.
Type without using the keyboard (on-screen keyboard)
http://Windows.Microsoft.com/en-us/Windows-Vista/type-without-using-the-keyboard-on-screen-keyboard
I hope this helps!
Halima S - Microsoft technical support.
Visit our Microsoft answers feedback Forum and let us know what you think.
-
Everytime I open Photoshop CS2, it starts as if it were the first time. All the settings are default and it asks me to register even though I already have. How do I save my settings and keep his memory?
Right-click on the exe to PS file and choose Run as administrator. I think you choose the option "check mail", it will not ask again.
-
I am trying to install CS5 on my iMac, after my computer crashed. I get a message saying that the software is already installed and will not install again. How can I install it again?
Hi Marleneb3511919,
I'm sorry for the inconvenience caused to you.
I guess you tried rebooting your system? If so, and the problem persists please try the steps listed in this document https://discussions.apple.com/thread/240851?start=0&tstart=0
Please let us know if this goes through.
Kind regards
Aurélie hamadi
-
Hi, I bought the creative cloud for a year. I uninstall and now I need to install it again, but whenever I connect my productnumber write he still wants me to buy the product I already bought. How to install after uninstalling it?
Please check the help below document:
Does not open App | Wheels of progress turn continuously
You can also view the nets below where this issue has been addressed:
Adobe Creative Cloud / Desktop App / Home Screen: constant spinning wheel
Creative Cloud Desktop App taped blue spinning wheel after update.
-
I'm stuck in limbo. I fell sick of the poor performance and constant crash of Windows 10 and back to Windows 7. I was warned that I may have to reinstall some software and was pleasantly surprised when nothing seemed to miss. Then I noticed that the new Acrobat Reader DC icon was just a white icon on the desktop.
Of course, the reader does not open when I clicked it, then I went to uninstall and reinstall. No go. The uninstall program complained that he was unable to find the. MSI file in the path with the big ugly GUID in there. I really care about the features of cloud of Document in any case, if I am I would like to install Acrobat Reader XI and finish with the DC version. Again, no go. The Setup program stops and a message that a newer version is already installed.
Next, I tried to reinstall the CD think that Setup is trying to fix the Bjorked version on the disc. No go. Once again the installation program complained that a newer version is already installed and bailed out without doing something useful.
So, I'm pretty damn good here because I can't go forward and I can't go back. Windows 7 uninstall tool think I installed Acrobat Reader XI and when asked to uninstall it still trying to dive into the folder Acrobat Reader DC and can not find the MSI file he seeks even if lead by the nose.
Setup of Acrobat Reader DC think that some superhuman drive versions are installed and will not install no matter how much I beg it.
What should I do?
Claudio,
I have found cleaners and tried both version 4 and version 2 as Windows uninstall although I still have version 11 on my system, but could not uninstall it. Even after using detergents and restarting, the installation of Acrobat Reader complained that it was a newer version of the PC alreadyon and came out of the installer.
I finally decided to remove all records of Adobe in C:\ProgramData and that did the trick. I was able to reinstall the version 11 player, and I think I'll stay with that after the nightmare of all clouds 'features' in Windows 10.
-
and how to pay download or activate my subscription? I already use the trial version, you can help me English. Thank you
If you had already installed the CC apps like tests, you can simply disconnect and reconnect with the good Email ID:
Connect and disconnect activate Cloud Creative applications
Feel free to ask, if you need additional help
-
I just paid to upgrade my acrobat reader, but it will not convert into Word because it is more than 100 MB. Just lost an hour of signing up and looking for help contact. How to cancel it without you guys give money for misleading me about your product? Thank you!
ICES.html https://helpx.adobe.com/x-productkb/Policy-Pricing/Cancel-subscription-Acrobat-Online-serv
You will need Acrobat to convert files > 100 MB.
[subject moved to cloud Document PDF Services forum]
-
Hi, I format the computer, I would like to know how the applications that I have, if I am already registered and then downloaded again...? !@
If you have a cloud account/subscription and then sign up before formatting. If you have a Creative Suite software license then before you format you must disable all the different suites opening one of the applications and selecting help-> Deactivate
The actions above will help make it easier for the reactivation of your subscription access/suite when you reinstall after format is done and your system restored.
-
Hi, I need to activate my Adobe CS3 on a new computer because my old is dead and I'm having trouble. Tried the average normal recording then connected with my Adobe ID and can see the software code and activation already registered. How to get it on my computer saved?
If your two activation is used, you need to call Adobe. Install CS3 point of activation and call Adobe at this time here. They help in cases like your My drive crashed and I replaced it. Could not disable the activation of the accident. I've done that twice in the years I use PS for about 20 years
To see your key, you must click on the product in your products and services Adobe page.
-
Hello
I am a student and I bought already cs6 (dvd) and would like to ask - is it possible to get an upgrade for cs6 premium
and how much it costs and how are they managing?
http://www.Adobe.com/au/products/creativesuite/UpgradeInfo.html
-
Firefox shows that it is already open and must be closed in order to update or delete. I can't locate a place to complete the process. It's probably something very simple, but I'm not a computer genius. Thank you!
Have you tried you look for firefox.exe in the Task Manager process tab (you can get to that by using Ctrl-Alt-Delete, usually)? If you click firefox.exe in the list and then click on end process, it should close Firefox, even if Firefox does not seem to be running (sometimes the process takes a little longer to close the main window). If all else fails, maybe a reboot?
-
WHEN YOU IMPORT MY VIDEOS THE SYSTEM FILES IN ONE DLL FILE FORMAT, HOW CAN I AVOID THS IN THE FUTURE AND WHERE THE
I FIND THIS FILE IN MY COMPUTER AND HOW EVEN OPEN. MY COMPUTER IS RUNNING WINDOWS VISTA HOME PREMIUM SERVICE
PACK 2. THANKS FOR YOUR HELP IN THIS ISSUE YOUR FORECAST AND BEST WISHES, ALAN.
What is the brand and model of the camera?
How_exactly_are to import you video files?
Maybe you are looking for
-
Program of applications Applications compatibility programs
Incompatible program after installation of Intuit Canada software is tax quick 2012. Message received that there is no compatibility mode Windows with this new software. What do you suggest me?
-
HP 250 G2: Coffee on laptop HP 250 G2
Hi a paid staff member a cup of coffee on his HP 250 Portable G2 screen has been damaged so I ordered a replacement screen and told him to back up his files just incase the screen isn't the only damage. I replaced the screen with a new job one I turn
-
I feel stupid asking this (microSD question)
But how do I actually put files on my microSD card and NOT on the internal memory of the rocket itself? I'm sure it's something incredibly simple and I feel like a fool for asking this, but I have looked through the user guides, many other sources an
-
Should I suspend for instant backup?
I have guests Windows 2008 R2, which are mainly used for the performance of work of statistical data and utilities such as printing, SFTP and application sharing. There are 2 running SQL, but not Exchange, Sharepoint, etc. Also some Linux Apache web
-
Remove the device detached using powershell scripts.
$E01 = get-esxcli - vmhost test01$ED01 = $e01.storage.core.device.detached.list () # I have 10 devices here$e01.storage.core.device.detached.remove ($ED01) error as followsPowerCLI C:\scripts > $e01.storage.core.device.detached.remove ($ed01)A specif