Select the first 20 days of the month for a given date

Hi gurus,

Please let me know to select the first 20 dates for a date supplied by using a parameter.

For ex -.

Suppose I provided a date by using a parameter - January 13, 2012

The query should return me - 01-Jan-2012, January 2, 2012... January 20, 2012

or if I get home on 23 March 2012

The query should return me - 01-Mar-2012, March 2, 2012... 20 March 2012

Thanks in advance.

Hello

Here's one way:

VARIABLE  target_date     VARCHAR2 (11)
EXEC     :target_date := '13-Jan-2012';

SELECT      TO_DATE ( SUBSTR (:target_date, 4)
            , 'Mon-YYYY'
           ) + LEVEL - 1     AS a_date
FROM     dual
CONNECT BY     LEVEL     <= 20
;

Note that this does not take account the part of: target_date that represents the day of the month. When you use TO_DATE without giving a date of the month, it defaults to the 1st of the month.

Tags: Database

Similar Questions

  • find the 3rd Friday of the month at a given date

    How can 3rd Friday of the month at a given date? I can always spend the first day of the month as input

    for example, the effective date is 1 January 09. need to get the 3rd Saturday 16 January 09 (Jan has 5 Friday 02, 09, 16,23,30)

    entry date: 1 February 09, needed 20 February 09

    Published by: user520824 on April 1st, 2009 12:30

    How about you...

    select trunc(sysdate,'mm') + (6 - to_char(trunc(sysdate,'mm'),'d')) + 14 from dual;
    
    TRUNC(SYS
    ---------
    17-APR-09
    
    select trunc(to_date('01-JAN-09'),'mm') + (6 - to_char(trunc(to_date('01-JAN-09'),'mm'),'d')) + 14 from dual;
    
    TRUNC(TO_
    ---------
    16-JAN-09
    
    select trunc(to_date('01-FEB-09'),'mm') + (6 - to_char(trunc(to_date('01-FEB-09'),'mm'),'d')) + 14 from dual;
    
    TRUNC(TO_
    ---------
    20-FEB-09
    
    select trunc(to_date('01-MAR-09'),'mm') + (6 - to_char(trunc(to_date('01-MAR-09'),'mm'),'d')) + 14 from dual;
    
    TRUNC(TO_
    ---------
    20-MAR-09
    
  • I called to cancel my subscription to the month for first adobe adobe support.  The representative told me that my membership was cancelled successfully.  But when I checked my account, it says my subscription needs to be renewed within a few days. Hoes i

    I called to cancel my subscription to the month for first adobe adobe support.  The representative told me that my membership was cancelled successfully.  But when I checked my account, it says my subscription needs to be renewed within a few days. Hoes it mean, the representative has not really cancelled my subscription?

    Hello

    You will need to contact support by calling/chat for this request.

    Contact the customer service

    * Be sure to stay connected with your Adobe ID before accessing the link above *.

    Kind regards

    Sheena

  • How to get the last day of a month for every 2 months for a given period?

    Hello

    Can is it some please let me know how to get the last day, last day of the week, the weekend last day, last Monday, one month for every 2 months for a given period?

    Thanks in advance.

    Try the below

    SELECT LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))) lastday.

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'SAT '.

    SO LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-1

    WHERE TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'Sun '.

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))-2

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    END as lastweekday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') IN ('Sam', 'SUN')

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    -(TO_NUMBER (TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))),' from)) - 1).

    END as lastweekendday,

    BOX WHEN TO_CHAR (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), 'DY') = 'MY

    THEN LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2)))

    Of OTHER NEXT_DAY (LAST_DAY (ADD_MONTHS (TRUNC(startdate,'MM'), ((LEVEL*2)-2))), "LUN")-7

    END AS lastmonday

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • How to get the second Monday of each month in a given date range?

    In Oracle forms, how to get the second Monday of each month in a given date range?

    I tried below using the query WITH the Clause, but it seems that WITH Clause does not work in Oracle forms. So is there another way to do this in Oracle forms?

    WITH month_range AS

    (

    SELECT TO_DATE ('Dec 2013', 'Mon YYYY') AS first_month

    , TO_DATE ('Mar 2014', 'Mon YYYY') AS last_month

    OF the double

    )

    SELECT NEXT_DAY (6 + ADD_MONTHS (first_month

    , LEVEL - 1

    )

    , 'MONDAY '.

    ) AS second_monday

    OF month_range

    CONNECTION OF LEVEL < = 1 + MONTHS_BETWEEN (last_month, first_month)

    ;

    Thanks in advance.

    Good fishing, when the first day of the month is Thursday... So I changed the query accordingly... Try the below

    SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'game '.

    THEN NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'THU')

    Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'Game') + 7

    END AS second_day

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • Is there an option to the month for the Plan of photography?

    Is there an option to the month for the Plan of photography?

    The $9.99 is based on an annual commitment. Is there an option with a higher monthly price that does not require an ongoing commitment?

    Hello

    I am sorry to say that the plan of the photograph is not available without annual commitment. You can choose options of payment such as monthly or annually.

  • The month for stock subscription is automatically renewed?

    The month for stock subscription is automatically renewed? I have to cancel to prevent-renewal if I just signed up for a month?

    It is renewed automatically on your billing date. Yes, you will need to cancel to stop paying.

  • I have problems, adding comments using Adobe reader DC on my pro 3 surface. I can select the circle for example, but when I try to draw the circle nothing happens and the screen just scrolls in the direction I move the pointer?

    I have problems, adding comments using Adobe reader DC on my pro 3 surface. I can select the circle for example, but when I try to draw the circle nothing happens and the screen just scrolls in the direction I move the pointer?

    Hey paulc6148125,

    Please try the mode settings different button in Adobe Acrobat Reader DC-> leModifiermenu-> preferences-> general categories.

    Kind regards

    Nicos

  • subscription to the month for creative cloud photoshop ended due to no money in bank account, it will b auto renewed once the money is there once again in the Bank? How to cancel it permanently?

    subscription to the month for creative cloud photoshop ended due to no money in bank account, it will b auto renewed once the money is there once again in the Bank? How to cancel it permanently?

    Liliane,

    To cancel the Member please contact our support team via: http://helpx.adobe.com/in/contact.html?step=CCSN_adobe-id-signing-in_stillNeedHelp

    If you cannot use the chat nicely option, try the steps mentioned below.

    • Try a different browser.
    • Clear cookies and cache

    If you are still not able to discuss, good response with the below mentioned information.

    • OS version:
    • Browser version:

    You can also try: http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

    For more information on the cancellation: https://helpx.adobe.com/x-productkb/policy-pricing/cancel-membership-subscription.html

    Atul_Saini

  • Select the query to select the month range based on the current date.

    It's the database 10 g oracel.

    I want to choose two months of data in the table. But these two months should be based on the current date.

    For example.

    If I run the select query on July 7, 2013, then the query must ignore the current month being July 2013 and last month, which is June 2013 and it shoud select only may 2013 and April 2013.

    Can someone help me how to make this request.

    SELECT *.

    FROM my_table

    WHERE my_date > = TRUNC (ADD_MONTHS (sysdate,-3), 'MY') - first day of the month 3 months ago

    AND my_date< trunc(add_months(sysdate,-1),'mon')="" --="" first="" day="" of="" last="">

  • SQL in Question actually. Select the items for all 12 months

    I am creating a notification request where I SUMMARIZED all of the amounts in the database for all 12 mount and come up with a result even if it isn't a amount totaled. I created a table called monthsInYear that has the ID (unique identifier) 1-12 and the months of Jan - Dec. I want SUM to the amount per month and arrived to the top with 12 results (one per month).

    I tried the query below, but sometimes with only 1 month and all amounts amounted to him.

    March484714.13

    I use:

    SELECT monthsInYear.month, IFNULL (SUM (income.amount), 0) AS amount

    OF monthsInYear

    Income ON EXTRACT(MONTH FROM income.dateAdded) = monthsInYear.monthID LEFT OUTER JOIN

    WHERE income.orgID = 10031

    AND the YEAR (income. DateAdded) = '2011'

    ORDER BY EXTRACT (MONTH FROM income.dateAdded) CSA

    Can someone tell me what I am doing wrong. I much prefer something like:

    January 3000

    February 3000

    March 4000

    April 0

    Maybe 5000

    June 6000

    July 5465

    ....

    But when I run the present, it gives me total for only the months which have in total and not 0 for those that go up as null. Any ideas?

    ....

    Also tried

    SELECT m.month, IFNULL (SUM (i.cost), 0) AS amount

    I have getExpenses LEFT OUTER JOIN monthsInYear m

    ON m.monthID = EXTRACT (MONTH FROM i.dateAdded)

    WHERE orgID = 10031

    AND YEAR (i.dateAdded) = '2011'

    GROUP BY m.month

    ORDER BY EXTRACT (MONTH FROM i.dateAdded) CSA

    There are two problems. First of all, in your join tables are reversed. A LEFT JOIN returns all the records in the left table (spending) even if there is no matching record in the table to the right. What you want, it's the opposite. If the month table should be on the left side of the JOIN:

    ...

    OF monthsInYear m LEFT JOIN getExpenses i m.monthID = EXTRACTION (i.dateAdded MONTH)

    Second, when there is no corresponding record in the expense, the column values will be null. So as soon as you use one of the fresh fields in your WHERE clause, that is to say

    WHERE i.orgID = 10031

    AND YEAR (i.dateAdded) = '2011'

    ... these missing documents are deleted, because a null value is never equal to what it is. So you are denying the outer join altogether. You must move these conditions in the JOIN clause instead:

    SELECT m.month, IFNULL (SUM (i.cost), 0) AS amount

    MonthsInyear LEFT OUTER JOIN getExpenses m I have

    ON m.monthID = EXTRACT (MONTH FROM i.dateAdded)

    AND i.orgID = 10031

    AND YEAR = 2011 (i.dateAdded)

    GROUP BY m.month

    ORDER BY m.month

  • Select the options for ALL but some in OBIEE prompt with a single click

    Hello guys,.

    I have the below requirement

    I have a prompt that displays the payment terms.

    On the result - 3 payment terms are the terms of payment we and the rest are Global.

    A user will select these 3 conditions of payment of the United States or the reset of the (Global) payment terms, but not all.

    Y at - it somehow I can create an option that selects all terms of payment with one click (as the option all columns)

    also, I'm trying to use all of the columns, which is to select all the columns including US and global, but once the user selects all the column option - the user is not able to selectively disable certain values.

    Is there a work around for this?

    Please let me know because this would be a great help for me.

    Thank you

    Why don't make you a second guest of the column where you add the CASE WHEN to produce the 2 types of terms (US & Global)?

    Then using the "limited by" you auto-filtre the actual list of terms of payment based on the first selection and is to meet your requirement to select all of the USA or Global all with just 1 click.

    The user you want to select just 1 term given? Just ignore the first field of the prompt with the groups and directly select the one required in the second field.

  • get the month and year of date type

    Hi all
    I need to get the month and year of type date.

    For example
    select to_date('2011-01-17', 'yyyy-mm-dd') from dual;
    Required result:
    01-2011
    Any ideas?

    Thanks in advance,
    Bahchevanov.
    select to_char(to_date('2011-01-17', 'yyyy-mm-dd'),'mm-yyyy') from dual;
    

    HTH

  • How can I dynamically select the shared Variable API programming data type?

    I am trying to create a configuration of open connections of variable shared using the programming API. It seems to me that the cleanest way to do would be to put one "open and check" routine in a loop, then call it for each variable in the library.

    The question that I am running is that I have different types of data in my library (to help a server Modbus i/o and data types 'boolean' and 'single' in my library.) How can I dynamically select the data type of the shared variable API?

    See the attached snipit.

    Thank you

    What I ended up doing was doing a Subvi to open, read, write, and close each data type, I use the packaged in 4 polymorphic SubVIs (polymorphic Open, read, etc...)

    Now all I have to do I drop in the polymorphic Subvi and it switches automatically to the appropriate data type

  • Impossible to select the host for the pool, can only select Cluster

    Hello

    I try to assess the view and go into the Guide of the evaluators.  When I set up the parameters of resource under the vCenter part settings of the linked Clone Pool where I'm supposed to be able to select a host or a Cluster, I have only the option to select my (not an individual host) cluster.  The problem is that not all hosts in my cluster have access to the SAN that I use for this assessment, so I wanted to be able to isolate the pool to a single host.  Is there some kind of trick to get the hosts present themselves individually?  The hosts are 5.5 ESXi and vCenter vCenter 5.5 Standard

    Thank you

    Dylan

    You can only select the cluster. "Host or a cluster" refers to the fact that if you have a stand-alone Host which is not in a cluster, you can use - so you'd have to move the host you want to use on a stand-alone host or in its own cluster.

    Mike

Maybe you are looking for

  • Qosmio F15-201: old BIOS version required

    Well, I changed my original BIOS and then ran into problems.And I did not backup old.So I need a new. Please help me on where it is located?This is for a Toshiba Qosmio F15 201 with a GeForce fx 5700 with 128 MB of memory. Here is some information on

  • Motherboard for Windows 8.1 updates 64-bit

    Hey guys! I encountered a problem, I have a desktop HP Pavilion HPE PC h9-1130 Phoenix but I guess I could say HAD one. I changed the GPU for a Nvidia GTX 760, put a H80 Corsair on the CPU to keep cooler and quieter while game, replaced the ram with

  • graphs

    Hello I want to see the values of the graph during mouse pointer points. But sometimes, it does not show values when placed at the points of the graph... Also when zoomed it shows values in these places where the points on the graph are not present..

  • Laptop HP G62, freezing, "Short DST Fail"

    Hello I have some major issues going on with my laptop.  I'm currently logged in Mode safe because whenever I'm in normal mode, now, the laptop charge apparently correctly, works of 3 1/2 minutes (Yes, I've timed it) and then freezes.  Any program th

  • try to determine the upgrade? XP pro to vista Home premium

    Hello my questions is can I upgrade or custom install a vista Home premium disc (come again with my wives computer dell Inspiron 1501) on my windows xp pro I tried to launch the Upgrade Advisor and readings of error unable to connect? Thanks sam