Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6125633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:16:14+00:00 2026-05-23T16:16:14+00:00

can i use to_number(to_char()) function in order to exclude all the weekends from a

  • 0

can i use to_number(to_char()) function in order to exclude all the weekends from a range of dates?

For instance, there are two date columns in my table such as start and finish (in the form of ’06/06/2011 10:00:00 am’), and i want to estimate the duration of finish-start excluding Saturdays and Sundays.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:16:14+00:00Added an answer on May 23, 2026 at 4:16 pm

    If I understand you right you want to calculate the difference between two dates, but exclude the 2 days of each weekend in the range from the result. Is that correct?

    If this is what you want the below code should work with the following assumptions:

    • I am assume start and end will not be on weekends.
    • I am not validating that end is before start.

    Basically its just a matter of working out how many weekends are in the date range. So obviously there’s one weekend per 7 days. Then we just have to check if the range wraps around a weekend, and if so add one more.

    FUNCION dateDiff( dt_start DATE, dt_end DATE ) RETURN NUMBER
    IS
        raw_diff NUMBER;
        weekends NUMBER;
    BEGIN
        raw_diff := dt_end - dt_start;
        weekends := TRUNC( raw_diff / 7 );
        IF( ( dt_start - TRUNC( dt_start, 'DAY' ) )
          > ( dt_end   - TRUNC( dt_end  , 'DAY' ) ) )
        THEN
            weekends := weekends + 1;
        END IF;
        RETURN raw_diff - ( weekends * 2 );
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a javascript function I can use to detect whether a specific silverlight
In the vxWorks shell, there are a number of routines you can use to
Is there anyway I can use to destroy my deployed application at specific date?.
Is there a .NET library I can use to programmatically generate my own GIF
Is it possible? Developers can use SMS URLs to populate the phone number, but
In a UNIX shell script, what can I use to convert decimal numbers into
I'm trying to use regexes to match space-separated numbers. I can't find a precise
HyperTerminal is a program that you can use to connect to other computers, Telnet
I'm wanting to write a method that I can use to initialise a Map.
i'm trying to create a ObjectDataSource which I can use to bind to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.