Number of days remaining in the month

Hi guys,.

I'm looking to create a function that returns the number of working days (Monday to Friday) between sysdate and the last day of the month.

If someone has done something similar.

I tried the following:

< code >

CURSOR days_c

IS

SELECT THE LEVEL

, to_char (LAST_DAY (ADD_MONTHS (SYSDATE-1)) + LEVEL,'Dy DD-Mon-YYYY "") AS DOW - day of the week

OF the double

WHERE ROWNUM < = EXTRACT (DAY FROM LAST_DAY (SYSDATE))

CONNECT BY LEVEL = ROWNUM;

v_cnt NUMBER: = 0;

BEGIN

FOR days_r IN days_c

LOOP

To_char (days_r.DOW) NOT AS "Sat %" If GOLD to_char (days_r.DOW) NOT LIKE '% of Sun '.

- AND to_date (days_r.dow) > sysdate

THEN

v_cnt: = v_cnt + 1;

END IF;

END LOOP;

RETURN v_cnt;

< code >

At the present time, IF logic around the days_r.DOW does not work as I am also bad to only return the greater these days but less dates at the end of the month.

Thanks in advance

Chris

Try this

SQL > with input_data
2 as
(3)
4. Select sysdate current_day
5, last_day (sysdate) last_day
6 double
7)
8. select count (*)
9 of)
10. Select current_day + (level - 1) d
input_data 11
12 connect
13 by level<= last_day="" -="" current_day="" +="">
14          )
15 where to_char (d, 'fmday') not in ('Saturday', 'Sunday');

COUNT (*)
----------
20

Tags: Database

Similar Questions

  • Number of days for all the months of the previous 10 years

    Hi guys,.
    I wonder if there is a way to insert in my table of data for the period dimension all
    days for the months of the year 2004,2005,2006,2007, etc..
    Is there somewhere in the Oracle database that stored the number of days for all the months of the years?
    I think I woud have to use a loop of the GET something like the following:

    -The year month day
    2004 - 1-1
    2004 1-2
    2004 1-3
    2004 1-4
    2004 1-5
    2004 1-6
    etc.
    Assuming that there are 28 or 29 or 30 or 31 days the lines for January 2004 would be 28,29,30 or 31.
    I need it for all the months and years.
    Thank you
    metalray

    Hello

    The following SQL returns all the days from 01/01/1970 until today:
    + (Just modify the FRST to What You Need).

    with beginat as (
    select trunc(to_date('1970/01/01','yyyy/mm/dd')) frst from dual
    )
    select frst+(level-1) as daydt
    from beginat
    connect by level <= ceil(sysdate-frst);
    

    With a previous alter session set nls_date_format = "dd/mm/yyyy hh24:mi:ss" result would be:

    DAYDT
    -------------------
    01/01/1970 00:00:00
    02/01/1970 00:00:00
    03/01/1970 00:00:00
    04/01/1970 00:00:00
    05/01/1970 00:00:00
    06/01/1970 00:00:00
    (...)
    09/01/2011 00:00:00
    10/01/2011 00:00:00
    11/01/2011 00:00:00
    
    14986 rows selected.
    

    In fact, the real question is: Why do you need them?
    (^_^)

    Published by: Nicosa January 11, 2011 14:25
    (for the correction)

  • Calculate the number of days remaining until the next anniversary. Help, please!

    Hi guys,.

    I'm new to the forum and to the development of BB. So please do not judge harshly if the answer to my question seems obvious.

    I need to calculate the number of days until the next birthday (taking into account any valid birth date)

    After looking at the API and the forum search, I realized that I could

    calculate the difference between two dates in milliseconds and then divide the delta of the value of a day in milliseconds. That is to say:

    birthdayCalendar.set (Calendar.YEAR, those);

    Date1 = birthdayCalendar.getTime () .getTime ();

    date2 = System.currentTimeMillis ();

    Delta = date1 - date2

    numOfDays = delta\DateTimeUtilities.ONEDAY

    Here's my question. How do I create a valid date1 what about leap years?

    Maybe there's a better way to solve this problem?

    Any help is greatly appreciated.

    I agree that the determination of the number of days between today and Feb. 29 could be a little difficult, if it is not a leap year.  I suspect that the calendar has a certain built-in mechanism to compensate for this, but your solution to choose a date is better.

    DST has a role to play, and Yes, the calendar makes up for it.  Let us take two dates, for example (before DST) March 1 and June 1 (after the DST).  If you take a calendar and set the same hour, minute, etc., they are all the same except for dates, then subtract one from the other, and then divide by the number of milliseconds in 1 hour, you calculate the number of hours between the same time on two different days.  You will find that it is not a multiple of 24 hours - because there is actually an hour less than the number of days since the clocks move forward (in the northern hemisphere anyway...),

    In your case, you are not calculating the number of hours, you calculate the number of days.  But you will be dividing by [24 * (time in an hour)].  If you take [23 * (time in an hour)] and divide it by [24 * (time in an hour)], using arithmetic on integers, you will end up 0.  The easiest to get around this, who also works for the end of the DST too, is to simply add one hour to the date before the division.

    Hope that makes sense...

  • Why do I get warnings about the number of days remaining in the trial period?

    I just bought and downloaded Acrobat Pro 11, but I still continues to be treated as if I had just downloaded the trial version. In other words, I get popups telling me I have so many days before the expiration of the free trial to the left. Also an update was denied, I think, because of this.

    Michael at this point, I recommend that you remove Adobe Acrobat by using the Control Panel programs and features.  Once this is done you can then run the cleanup tool http://labs.adobe.com/downloads/acrobatcleaner.htmlAcrobat.  Once you have run the delete please wash all other shortcuts on your desktop and try to reinstall Adobe Acrobat via Adobe Application Manager.

  • I bought Photoshop CC 2015 creative thinking Cloud before running the trial version of my computer. After you have installed the creative cloud, the box with the number of days remaining still apears. How can I proceed?

    I bought Photoshop CC 2015 creative thinking Cloud before running the trial version of my computer. After you have installed the creative cloud, the box with the number of days remaining still apears. How can I proceed?

    Check your account indicates the subscriptions that you expect (and that the adobe, used in the next step id is correct) by logging in here and checking the status of your subscription, https://www.adobe.com/account.html

    then, if it's current, disconnect and then back to your client application using the adobe with the link above in cc id: http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    If this fails, CC help | Applications creative Cloud back to update evaluation Mode to 2015 CC

  • need to replace my number of credit card for the monthly payment. What they suggest to do, does not take me anywhere. Is there any phone number to call to expedite this update?

    I need to replace my number of credit card for the monthly payment. What they suggest to do the update your credit card number does not take me anywhere. You is any phone number to call to speed this up?

    Francosp

    Ensure that EACH DETAIL is the same in all places, you enter your information

    -in how to spell and punctuate the parts of your name and address

    Change/Verify account https://forums.adobe.com/thread/1465499 can help

    - Https://helpx.adobe.com/utilities/credit-card.html credit card

    -or by phone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Count of the number of days in a calendar month according to the year

    Hi all

    On my table, column 1 is the list of months over several years.

    Column 2 is the activity number od each month.

    Column 3 I want an average rate of activity per day during the month, which should be: (C2 / number of days according to C1) %

    Problem: I can't find a fomula give me the number of days, particularly in February when the year is leap.

    Any help is appreciated.

    Thank you all,

    Lopez

    PS: by the way, with this new version of Apple Comunity I seem to have lost my previous questions about the numbers.

    Hey Lopez,

    EOMONTH(A1,0) (end of month) will GET help you.

    Column B is Date & time format to display only the month and year (actually the 1st of the month, but the day is not displayed).

    Formula in C2 (fill down)

    = EOMONTH(B2,0)

    The end of the month 0 months later.

    Formula in D2 (fill down)

    = DAY (C2)

    February 2015 (non-leap years) shows 28

    February 2016 (leap year) shows 29

    Kind regards

    Ian.

  • Number of days worked if the criteria of

    I'm looking for a formula counting the number of days, I worked my last day of rest, sheet 1, if it meets the date displayed in cell D2 in sheet 2, which is the Start Date and time after my rest day.

    sheet 1 has the info.

    D = 'Date' Date and time format

    E = "Duration" personalized hr: mm (start time)

    F = "Duration" hr: mm custom (arrival time)

    G = "Duration" hr: customized mm (total length)

    sheet 2

    D2 has a sum which adds the sheet 1::Table 1::D2 + 1::Table Sheet 1::E2 equals 03/12/16 17:50.  Format: Custom, Date & time, Format custom: 05/01 07:08 drag token or text etc.

    Any ideas how I can do this please.

    Thanks David

    Hi David,

    I don't get a clear idea of what you're trying to do. Can clarify you, perhaps with a screenshot showing examples of the values in the cells involved?

    Kind regards

    Barry

  • Automatically remove folders in number random/letter remains at the root of the C drive of Windows updates?

    How to automatically delete the files random number/letter remains at the root of the C drive of Windows updates?  I push automatically updates Windows via GPO and require a similar solution to automatically remove these remains of Windows Update installation files.

    I know not how to remove manually, but circulating at each work station is simply not practical. There must be an easier way.  Help, please.

    It is a specific consumer support forum. Post here instead-online http://social.technet.microsoft.com/Forums/en/itproxpsp/threads

  • Calendar events hotmail disappeared days corresponding to the monthly calendar

    My hotmail calendar displays more events that I posted in my monthly calendar display.  They appear at the far left of the first day of each week in the monthly calendar.  They appear correctly in all other views of the calendar.  This just happened recently.  What can I do about it?

    Hello

    I'm sorry, but we cannot help with hotmail problems in these forums in response to vista

    Please repost your question in hotmail in the hotmail link below forums

    http://windowslivehelp.com/product.aspx?ProductID=1

    Forums
  • Creating cloud apps, saying 'Buy now' 3 days remaining after the purchase of 2 licenses

    My creative Cloud (Photoshop CC etc) applications say 'Buy now' 3 days left... after the purchase of 2 licenses for our company. I now have 3 days left the trial. We managed to install a license on a PC but not the other. I try to install the license 2nd on an iMac, please help!

    janines2001,

    If it please try to disconnect from the creative cloud and reconnect. Please check:

    Let us know if that helps.

  • Days remaining to the test?

    I downloaded a trial of Adobe after effects CC 2014 thanks to the application of creative cloud on windows. How can I check the days left on my trial?

    BrandoDando you will receive an update every day, you need to launch the application.  The notification will go up to the first launch.

  • Function to return the number of days in a month?

    In one of my rules, I need to allocate an amount of benefits based on the number of days remaining in the calendar month.

    OPM does have a function that can provide me with the number of days in a calendar month?

    Thank you very much
    Isamu

    It is not a direct function to do this, however, it can be done with a bit of messing around. The following rules you will get the number of days of the month of the date of the date

    Basically, you get the first day of the month, add a month to the first day of the following month and then get the number of days between them, which will give you the number of days of the month of the date

    the month = ExtractMonth(the date)
    the year = ExtractYear(the date)
    the start of the month =MakeDate(the year, the month, 1)
    the start of the next month = AddMonths(the start of the month, 1)
    The number of days in the month = DayDifference(the start of the month, the start of the next month)
    

    These rules can be a little more compact, but it is basically how to do it.

  • How to get the number of days in a month of belonging to a range of dates

    Hi, I'm going crazy around a problem, I have 2 dates and one month I wanto to retrieve the number of days belonging to the months that fall within the range.

    for example:

    month of January 2011. begin_date = January 11, 2011, May 30, 2011 end_date result is 21
    month of January 2011. begin_date = December 11, 2010, result of end_date, January 10, 2011 10
    month January 2011 .begin_date = 2 February 2011, end_date may 25, 2011 result 0
    month of January 2011. begin_date = January 3, 2011, January 5, 2011 result DATE END 3

    and so on...

    I appreciate any suggestion
    Thank you


    Andrea

    Something like that... ?

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual)
      5  select least(last_day(to_date(mnth,'Mon-yy')),to_dt) -
      6         greatest(to_date(mnth,'Mon-yy'),from_dt) cnt
      7  from t  ;
    
           CNT
    ----------
            20
    

    If 0 is also expected...

    SQL> with t as
      2  (select  to_date('11/01/11','dd/mm/yy') from_dt,
      3           to_date('30/05/11','dd/mm/yy') to_dt,
      4           'Jan-11' mnth from dual union all
      5           select  to_date('11/01/11','dd/mm/yy') from_dt,
      6           to_date('30/05/11','dd/mm/yy') to_dt,
      7           'Jan-12' mnth from dual
      8           )
      9  select from_dt,to_dt,mnth,
     10         greatest(
     11              least(last_day(to_date(mnth,'Mon-yy')),to_dt)
     12              -
     13              greatest(to_date(mnth,'Mon-yy'),from_dt)
     14                 ,0) cnt
     15  from t;
    
    FROM_DT   TO_DT     MNTH          CNT
    --------- --------- ------ ----------
    11-JAN-11 30-MAY-11 Jan-11         20
    11-JAN-11 30-MAY-11 Jan-12          0
    

    Published by: JAC on February 9, 2012 19:22

  • Get the number of days, months and year

    Hi all

    I'm using OBIEE 11 g. I have a line of dash for year (2010, 2011, etc.) and months (Jan, Feb,..., Dec). How can I get the number of days in a given month and year in my report?

    For example, if I choose to Jan & 2011, I'd get 31 and 356. And if I choose Feb & 2011, I would get 28 and 356.

    Thank you!

    I have something more good option here... Try to use this

    DAYOFMONTH (TIMESTAMPADD (SQL_TSI_DAY, DAYOFMONTH (CURRENT_DATE) *-1, TIMESTAMPADD (SQL_TSI_MONTH, 1, CURRENT_DATE)))

    This will give you the days for the month in progress (Oct 2011) after calculating the last day of each month... Similary dynamically pass the value Date or month... You will need to modify this function but shud be simple. Hope this helps :)

Maybe you are looking for

  • Display does not turn off when attached to the ear during a call

    When you hold my iPhone 6 up to my ear during a call, the screen is not turn off and disable the buttons. The sensor is not broken, because the auto brightness works very well. It is just inside the calls when he won't work. Is there a setting to tur

  • Rn312

    Hello Is anyone know normal external operatig for redynas 312 Temp drive CPU temperature Rotation of the fan Any good help THX

  • 2301AX support for Hitachi HTS721010A9E630

    Hi all I have the laptop HP Pavilion 2301AX g6, which has HTS545050A7E380 Hitachi 500 GB 5400 RPM HARD drive. However, I plan to upgrade my laptop Hitachi Hitachi HTS721010A9E630 1 TB 7200 RPM HARD drive. My question is, if this HARD drive supported

  • HP Deskjet 6122:6122 prints all colors

    My HP 6122 printer prints all colors.  I put new cartridges in three.  Printed black and blue only.  Another print clear yellow, pink and black.  A black and in some parts of the document print prints a pink light.  I cleaned the cartridges and also

  • Where is my option "home"?

    Home option is missing after hard reset. Cannot apply to any pitcher, so do not even Google instant.