Hi!
There are two given dates and I have to find out the working days between two dates i.e. excluding Sundays. Please help. Thank you.
5 31365
Hi!
There are two given dates and I have to find out the working days between two dates i.e. excluding Sundays. Please help. Thank you.
Try this: -
-
SELECT dt FROM
-
(SELECT TO_DATE(:start_date,'DD-MON-YYYY') + level - 1 dt FROM table_name CONNECT BY level <= TO_DATE(:end_date,'DD-MON-YYYY') - TO_DATE(:start_date,'DD-MON-YYYY')) WHERE TO_DATE(dt,'Day') != 'Sunday';
-
-
PS: Not Tested!!
Hi!
There are two given dates and I have to find out the working days between two dates i.e. excluding Sundays. Please help. Thank you.
MODIFIED OF AMITH PETELS CODE -
-
SELECT HIREDATE FROM
-
(SELECT TO_DATE(&start_date,'DD-MON-YYYY') + level - 1 HIREDATE FROM EMP
-
CONNECT BY level <= TO_DATE(&end_date,'DD-MON-YYYY') - TO_DATE(&start_date,'DD-MON-YYYY') )
-
WHERE TO_DATE(HIREDATE,'Day') != 'Sunday'
-
/
-
Try this: -
-
SELECT dt FROM
-
(SELECT TO_DATE(:start_date,'DD-MON-YYYY) + level - 1 dt FROM table_name CONNECT BY level <= TO_DATE(:end_date,'DD-MON-YYYY) - TO_DATE(:start_date,'DD-MON-YYYY')) WHERE TO_DATE(dt,'Day') != 'Sunday';
-
-
PS: Not Tested!!
-
-
WITH date_tab AS
-
(SELECT TO_DATE ('&from_date', 'dd-MON-yyyy')
-
+ LEVEL
-
- 1 business_date
-
FROM DUAL
-
CONNECT BY LEVEL <=
-
TO_DATE ('&to_date', 'dd-MON-yyyy')
-
- TO_DATE ('&from_date', 'dd-MON-yyyy')
-
+ 1)
-
SELECT business_date
-
FROM date_tab
-
WHERE TO_CHAR (business_date, 'DY') NOT IN ('SAT', 'SUN');
-
//
-
-
-
CREATE OR REPLACE FUNCTION F_BUSINESS_DAYS
-
(V_START_DATE IN DATE, V_END_DATE IN DATE)
-
RETURN NUMBER IS DAY_COUNT NUMBER := 0;
-
CURR_DATE DATE;
-
BEGIN -- loop through and update
-
CURR_DATE := V_START_DATE;
-
WHILE CURR_DATE <= V_END_DATE
-
LOOP
-
IF TO_CHAR(CURR_DATE,'DY') NOT IN ('SAT','SUN')
-
THEN DAY_COUNT := DAY_COUNT + 1;
-
END IF;
-
CURR_DATE := CURR_DATE + 1;
-
END LOOP;
-
RETURN DAY_COUNT;
-
END F_BUSINESS_DAYS;
-
//
-
-
Dear Subhashsavji,
The solution (WITH date_tab AS ) works fine...great query.
Many Thanks.
Also check this for more customized version.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Stockwell |
last post by:
I''m wondering if the Calendar object has an option to only do calculations
based on business days (ie M-F). Additionally does it have a way to get...
|
by: Anthony Robinson |
last post by:
Is anyone aware of a function (system or user defined) that will
calculate business days? For instance: I have a column in as table
called DATE. I...
|
by: igendreau |
last post by:
I have users inputting a "Request Date". Upon entering a date, I need
Access to populate a second field ("Due Date"). When they enter their...
|
by: CDMAPoster |
last post by:
I'm starting to come up with a version of DateAdd that I call
BusinessDateAdd that adds the selected number of business days. It's
still in...
|
by: Sam |
last post by:
Hi,
I use C# in my ASP.NET projects. Here's what I need to do: I want to add x
business days to a given date i.e. add 12 business days to today's...
|
by: brains4math |
last post by:
Hi, is there a method in C# that calculates the number of business
days between given dates, like networkdays in Excel?
Thank you!
|
by: =?Utf-8?B?QWw=?= |
last post by:
I am working in vb2005. how can I calculate business days (not including
holidays and weekends) between 2 dates? thanks
Al
|
by: santhoshrms |
last post by:
I need to be able to determine the number of business days between two dates. Is there a function/Select Query in DB2 that can be used to do this? ...
|
by: FishVal |
last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL.
...
|
by: Jerry Maiapu |
last post by:
Ok, I found a function that calculates/count business days excluding Weekends and holidays on the net.
My country's Holiday dates are in a table...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
| |