find the first day of the month

Hello...
can u pls let me know how to find the first day of the month, if the number of months (for ex - OCT-10) is passed as input

Kind regards

I'm not sure that there is a function called FIRST_DAY().

SQL> SELECT first_day (SYSDATE)
  2    FROM DUAL;
SELECT first_day (SYSDATE)
       *
ERROR at line 1:
ORA-00904: "FIRST_DAY": invalid identifier

SQL> SELECT TRUNC (SYSDATE, 'month')
  2    FROM DUAL;

TRUNC(SYS
---------
01-DEC-08

SQL> 

I hope this helps.

Kind regards
Joice

Tags: Database

Similar Questions

  • To find the months and days between 2 dates

    Hello

    I want to find the months and days between 2 dates.

    For example.

    1 - Date: August 25, 2013

    2 - Date: October 23, 2013

    If we consider each month 30 days, it should give

    August 25, 2013 to August 30, 2013 = 6 days

    01-Sep-2013-30-Sep-2013 = 1 month

    October 23, 2013 to October 30, 2013 = 8 days

    Total = 1 month and 14 days.

    Kindly help as soon as possible.

    Thanks and greetings

    Suresh

    Assuming that d2 > d1,.

    where d)

    Select sysdate d1, sysdate + 56 double d2

    Union all select to_date (March 1, 2013 ',' dd-mon-yyyy "") d1, to_date (March 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (5 February 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (February 25, 2013 ',' dd-mon-yyyy "") d1, to_date (March 23, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (February 25, 2013 ',' dd-mon-yyyy ') d1, to_date (March 31, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (August 2, 2013 ',' dd-mon-yyyy "") d1, to_date (29 October 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (February 1, 2013 ',' dd-mon-yyyy "") d1, to_date (May 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (25 August 2013 ',' dd-mon-yyyy "") d1, to_date ('03-Sep-2013', 'Mon-dd-yyyy') d2 double

    Union all select to_date (July 30, 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (August 30, 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (July 31, 2013 ',' dd-mon-yyyy ') d1, to_date (3 August 2013 ',' dd-mon-yyyy "") double d2

    Union all select to_date (3 July 2013 ',' dd-mon-yyyy "") d1, to_date (August 31, 2013 ',' dd-mon-yyyy ') d2 double

    Union all select to_date ('31-08-2013', ' dd-mm-yyyy'), to_date('05-10-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('31-03-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-03-2013','dd-mm-yyyy') of the double

    Union all select to_date ('05-02-2013', ' dd-mm-yyyy'), to_date('05-02-2013','dd-mm-yyyy') of the double

    )

    Select d1, d2,

    1 + 30 * trunc (months_between (d2, d1)) + LESS (extract (day of d2), 30)-LESS (excerpt (d1 day), 30)

    + CASE when extracted (d2 day)< extract(day="" from="" d1)="" then="" 30="" else="" 0="" end ="">

    d

    D1 D2 DAYSBETWEEN

    ----------- ----------- -----------

    October 10, 2013 5 December 2013 56

    March 1, 2013 30 March 31, 2013

    5 February 2013 March 31, 2013 56

    February 25, 2013 March 23, 2013 29

    February 25, 2013 March 31, 2013 36

    August 2, 2013 29 October 2013 88

    February 1, 2013 may 31, 2013 120

    August 25, 2013 03 - Sep-2013 9

    July 30, 2013 31 August 31, 2013

    July 31, 2013 August 30, 2013 31

    July 31, 2013 3 August 2013 4

    July 3, 2013 August 31, 2013 58

    31 August 2013 5 October 2013 36

    5 February 2013 March 31, 2013 56

    5 February 2013 March 5, 2013 31

    February 5, 2013 February 5, 2013 1

    In my view, which corresponds to your rules.

  • where can I find the monthly subscription?

    where can I find the monthly subscription?

    Hey julietteh55830290,

    Before include files, make sure that they have been converted to PDF format.

    See this KB doc. Document Cloud Help | Adobe PDF package using.

    Kind regards

    Nicos

  • First day of a month

    Hello

    Can someone help me to write a code when a random day is given a month, that the day should change automatically
    in the first day of a month.

    Can you give an example?
    Do you mean the last day of the month for a random date?
    Then you can simply use builltin Oracle LAST_DAY function:

    SQL> select sysdate from dual
      2  union
      3  select last_day(sysdate) from dual;
    
    SYSDATE
    -------------------
    03-05-2012 18:17:04
    31-05-2012 18:17:04
    
  • First day of the month between 08:00 and 18:30

    DB version: 10.2.0.4

    Due to the nature of our the first working day of each month (like today 1 MS), the DB will be very busy.
    We execute a proc purge planned Windows Scheduler every 5 minutes every day.

    But the first day of every month (like today 1 MS), if it's a day of the week (Monday to Friday) we do not want this proc running between 08:00 and for dinner from 18:30.

    So, I thought including the logic in the procedure itself.

    How can I implement this?

    Edited by: user872043, Sep 1 2010 08:48

    Here is an example of using DBMS_SCHEDULER which should meet your needs:

    Create schedules

    BEGIN
            DBMS_SCHEDULER.CREATE_SCHEDULE
            ( schedule_name   => 'every_5_schedule'
            , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31; INTERVAL=5; BYSECOND=0'
            , comments        => 'Schedule to run every 5 minutes'
            );
    
            DBMS_SCHEDULER.CREATE_SCHEDULE
            ( schedule_name   => 'busy_hourly_schedule'
            , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=0,1,2,3,4,5,6,7,19,20,21,22,23; INTERVAL=5;'
            , comments        => 'Schedule to run every 5 minutes except certain hours on the first of the month'
            );
    
            DBMS_SCHEDULER.CREATE_SCHEDULE
            ( schedule_name   => 'busy_6pm_schedule'
            , repeat_interval => 'FREQ=MINUTELY; BYMONTHDAY=1; BYHOUR=18; BYMINUTE=30,35,40,45,50,55'
            , comments        => 'Schedule to run every 5 minutes from 6:30 - 7'
            );
    END;
    /
    

    There are three lists.

    every_5_schedule - runs every 5 minutes for all the days that are not on the first day of the month
    busy_hourly_schedule - runs every 5 minutes for the acceptable hours on the first day of the month
    busy_6pm_schedule - retrieves the half hour from 6:30 - 7 on the first day of the month.

    Then, create your business:

    Job creation

    BEGIN
            DBMS_SCHEDULER.CREATE_JOB
            ( job_name        => 'YOUR JOB'
            , job_type        => 'PLSQL_BLOCK'
            , job_action      =>'BEGIN YOURPROC; END;'
            , repeat_interval => 'EVERY_5_SCHEDULE, BUSY_HOURLY_SCHEDULE, BUSY_6PM_SCHEDULE'
            , enabled         => TRUE
            , comments        => 'Some comments'
            );
    END;
    /
     
    

    HTH!

  • Number of days in a month

    I have created a form with 2 date objects:

    "Date1" is a date object in which the user will enter the first day of a month gave "MM/DD/YYYY";

    I need "Date2" to calculate the last day of the month of 'Date1' ' MM/DD/YYYY ".

    Obviously, the date displayed in Date2 will vary, because months contain a different number of days, so I can't just say '+ 30 '. Can someone help me with a JavaScript for the FomCalc code to achieve this?

    Thank you!!!

    Gene-O

    Maybe you're view model is different from the trend in the script.

    Here is an example of work form:

    https://Acrobat.com/#d=rqvjWvn5WIBrWD * GLDRgfA

  • How to find the first day of the month following two years one year from now?

    Hello

    I need to find the first day of the month following two years ago, based on the current date.

    For example: If today is the 31/08/2015 so I need to find the date range between 31/08/2015 and on 09/01/2013. How can I write an SQL which allows to automate this calculation instead of hard-coding the values. Please do help me out with this so that I can build the SQL that can produce the desired result.

    Thank you

    Dhilip

    find the start of the month - 2 years in advance, early - 2 years + 1 months in advance and go back 1

    Select trunc (add_months(sysdate,24), 'MM'), trunc (add_months(sysdate,25), 'MM') - 1 double;

  • How to find the first Sunday and the second Saturday of each month

    Hi all

    How to find the first Sunday and the second Saturday of each month

    Thank you

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    994122 wrote:

    Hello

    I need to pass the months parameter how to do this? like Jan, Feb etc... (one of those)

    Do you have a procedure?

    Should you output only for the months you passed in the parameter?

    The easiest way is to set the parameter as date. When you go such as p_date as DATE ' 2014-10-01', then you can

    PROCEDURE two_dates)

    p_date IN DATE

    p_first_sunday DATE

    p_second_saturday DATE

    )

    IS

    BEGIN

    p_first_sunday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-12', 'DAY'));

    p_second_saturday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-11', 'DAY')) + 7;

    END two_dates;

    Or you describe what you need.

  • What cancellation would be paid should I cancel the month by month plan ' photography' after the first 14 days?

    Adobe said that after the first days 14 cancellation period of reflection would make me responsible for '50% of the remaining contract obligation '. I can't find another explanation as to what is the obligation of contract. Common sense would make me think that would mean 50% billable months remaining. However, the lack of transparency makes me suspicious that it could be defined as the total of the annual contract.

    Can someone tell me permanently? And show me where in the terms it says this?

    Thanks in advance

    R

    The contract is for 12 months. If you cancel after cooling then you pay 50% of however much of the 12 months is remaining.

    Adobe - General conditions of subscription

  • Find the first day of the third quarter of next year

    Hello

    I'm writing a sql to find "the first day of the third quarter of the year (from the current year) next»

    I am able to get the first and the last day of the current quarter:

    Select trunc (sysdate, 'Q'), trunc (add_months (sysdate, + 3), 'Q')-1 double

    But, how to find the first day of the third quarter of the year next (from the current year) based on any date entry (i.e. sysdate)

    for example if my entry date = 12/01/2001 should be released 07/01/2015

    If my entry date = 07/04/2005 should be released 07/01/2015

    If my entry date = 20/02/2013 should be released 07/01/2015

    ... etc.

    Thanks in advance

    Hello

    The 1st day of the 3rd quarter of next year is:

    ADD_MONTHS (TRUNC (SYSDATE, 'YEAR')

    18 = 12 + 6

    )

    TRUNC (SYSDATE, 'YEAR') is the 1st day of the 1st quarter of this year

    The first day of the new year is 12 months after that, and the first day of quarter 3 is another 6 months after that.

    user634169 wrote:

    ... But, how to find the first day of the third quarter of the year next (from the current year) based on any date entry (i.e. sysdate)

    for example if my entry date = 12/01/2001 should be released 07/01/2015

    If my entry date = 07/04/2005 should be released 07/01/2015

    If my entry date = 20/02/2013 should be released 07/01/2015

    ... etc.

    Thanks in advance

    You did some errors above?

    If the effective date in 2001, why is the output in 2015, not 2002?

    If the output is based only on the date of the day (currently in 2014), why even mention a start date?

  • First day of the month

    How to find the first day of the month if the month format is like TO_CHAR(SYSDATE,'YYYYMM')
    
    Sanjay
    Published by: user12957777 on May 23, 2012 21:12

    There is no 'day' in this date format.

    What you trying to do? What do you expect the result to look like?

    Are you wanting to set a date for the first day of the month and year of your example?

    SELECT TO_DATE(TO_CHAR(SYSDATE,'YYYYMM') || '01', 'YYYYMMDD') FROM DUAL;
    
  • How to calculate the first day of the month following in BI Publisher

    I need to be able to calculate the first day of the month of a date field in a BI Publisher model. The field name is COL_CLM_180 and contains a date in the format "YYYY-MM-DD". I have found so far any documentation that still gives me an idea of what to do.

    Any help or advice would be appreciated

    Hi - thank you very much for your help. Your last answer got me going in the right direction and I indeed was dense. I don't know why I don't think to the calculation in the original query. I put the statement: TRUNC (ADD_MONTHS(A.COL_CLM_180,1), 'MM') in a column in the query of conduct and it has worked flawlessly. Thank you - thank you - thank you.

  • query for the first day of the month

    Hi all

    How to get the first day of the month in the sql query.

    SQL> select trunc(sysdate,'mm') first_day from dual;
    
    FIRST_DAY
    ---------
    01-AUG-15
    
    SQL> select trunc(sysdate,'month') first_day  from dual;
    
    FIRST_DAY
    ---------
    01-AUG-15
    
    SQL> select trunc(sysdate,'mon')  first_day from dual;
    
    FIRST_DAY
    ---------
    01-AUG-15
    
    SQL>
    
  • first day of the month and time

    Hello

    Using oracle 11.2.0.3

    A table with a column date

    sample opening time data 04/08/2014-08:30 one single column, another column start date 04/02/2014

    Want to have a sql that will go through an opening time table set on the first day of the month as well as existing time

    for example expect times to be

    04/01/2014 08:30

    Code below will give the first day of the month

    What is the best way to achieve this-date data type columns.

    {code}

    Select trunc(start_time,'MM))

    of customer_hours ch

    {code}

    Select

    SYSDATE - trunc (sysdate) + trunc (sysdate, 'MM')

    of the double

    resp.

    Select

    start_time - trunc (start_time) + trunc (start_time, 'MM')

    of the double

  • Breaking a year in coming weeks of beginning and end Dates (parameters) and first and last day of the month

    Hello people:

    I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.

    Any help or pointers would be great!

    Thank you!

    Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).

    The request in hand:

    SELECT first_thursday + (7 * (LEVEL - 1))   AS week_start_date,
                     first_thursday + (7 * LEVEL) - 1    AS  week_end_date
    FROM
    (
      SELECT TRUNC(p_from_date + 4, 'IW') - 4   AS first_thursday, -- Week should start the pre ceeding THURSDAY based on the Start Date
                      TRUNC( p_to_date + 4,  'IW') - 5     AS last_wednesday
      FROM
      (
        SELECT to_date('01-JAN-2013') AS p_from_date,
                        NVL(to_date('31-DEC-2013'), SYSDATE) AS p_to_date
        FROM     dual
      ) parms
    ) end_points
    CONNECT BY LEVEL <= ( last_wednesday + 1 - first_thursday)/7;
    

    Currently, this is the result I get (I'm only including the months of January and December here).

    Week_Start_Date     Week_End_Date
    27-DEC-12                02-JAN-13
    03-JAN-13                 09-JAN-13
    10-JAN-13                 16-JAN-13
    17-JAN-13                 23-JAN-13
    24-JAN-13                 30-JAN-13
    31-JAN-13                 06-FEB-13
    

    December:

    28-NOV-13               04-DEC-13
    05-DEC-13              11-DEC-13
    12-DEC-13              18-DEC-13
    19-DEC-13              25-DEC-13
    

    What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:

    January:

    01-JAN-13              02-JAN-13
    03-JAN-13              09-JAN-13
    10-JAN-13             16-JAN-13
    17-JAN-13             23-JAN-13
    24-JAN-13             30-JAN-13
    31-JAN-13             31-JAN-13
    

    February:

    01-FEB-13    06-FEB-13
    07-FEB-13    13-FEB-13
    14-FEB-13    20-FEB-13
    21-FEB-13    27-FEB-13
    28-FEB-13    28-FEB-13
    

    November:

    31-OCT-13    06-NOV-13
    07-NOV-13    13-NOV-13
    14-NOV-13    20-NOV-13
    21-NOV-13    27-NOV-13
    28-NOV-13    04-DEC-13
    

    December:

    01-DEC-13           04-DEC-13
    05-DEC-13           11-DEC-13
    12-DEC-13          18-DEC-13
    19-DEC-13          25-DEC-13
    26-DEC-13          31-DEC-13
    

    Hello

    Roxyrollers wrote:

    Hello people:

    I have currently a query that picks up all the weeks between a date range where my week starts on Thursday and ends on Wednesday. The following query works fine except that I need the week of beginning and end, from beginning and end Dates of months and the beginning and the Dates of end of the values of the settings, I'm passing. In this case, I chose January 1, 2013 to 31 December 2013.

    Any help or pointers would be great!

    Thank you!

    Problem: I am picking up days of December 2012 as the first week began on December 27, 2012. In addition, in December, I'm pretty much lost last week as well (26 December - 31 December).

    The request in hand:

    1. First_thursday SELECT + (7 * (LEVEL - 1)) AS week_start_date,
    2. first_thursday + (7 * LEVEL)-1 AS week_end_date
    3. Of
    4. (
    5. SELECT TRUNC (p_from_date + 4, 'IW') - 4 AS first_thursday,-week should start to perform the pre-mounted THURSDAY based on the Start Date
    6. TRUNC (p_to_date + 4, 'IW') - 5 AS last_wednesday
    7. Of
    8. (
    9. SELECT to_date('01-JAN-2013') AS p_from_date,
    10. NVL (to_date('31-Dec-2013'), SYSDATE) AS p_to_date
    11. OF the double
    12. ) parms
    13. ) end_points
    14. CONNECT BY LEVEL<= (="" last_wednesday="" +="" 1="" -="">

    Currently, this is the result I get (I'm only including the months of January and December here).

    1. Week_Start_Date Week_End_Date
    2. DECEMBER 27, 12 2 JANUARY 13
    3. JANUARY 3, 13 JANUARY 9, 13
    4. 10 JANUARY 13 JANUARY 16, 13
    5. 17 JANUARY 13 23 JANUARY 13
    6. 24 JANUARY 13 30 JANUARY 13
    7. 31 JANUARY 13 FEBRUARY 6, 13

    December:

    1. NOVEMBER 28, 13 4 DECEMBER 13
    2. 5 DECEMBER 13 DECEMBER 11, 13
    3. 12 DECEMBER 13 18 DECEMBER 13
    4. 19 DECEMBER 13 DECEMBER 25, 13

    What I would really like is based on start and end Dates, as well as the first and the last day of the month is similarly try nicely. I have provided and then gently break at the end of the month:

    January:

    1. JANUARY 1, 13 2 JANUARY 13
    2. JANUARY 3, 13 JANUARY 9, 13
    3. 10 JANUARY 13 JANUARY 16, 13
    4. 17 JANUARY 13 23 JANUARY 13
    5. 24 JANUARY 13 30 JANUARY 13
    6. 31 JANUARY 13 JANUARY 31, 13

    February:

    1. 1ST FEBRUARY 13 FEBRUARY 6, 13
    2. 7 FEBRUARY 13 FEBRUARY 13, 13
    3. 14 FEBRUARY 13 FEBRUARY 20, 13
    4. 21 FEBRUARY 13 FEBRUARY 27, 13
    5. 28 FEBRUARY 13 FEBRUARY 28, 13

    November:

    1. 31 OCTOBER 13 NOVEMBER 6, 13
    2. 7 NOVEMBER 13 NOVEMBER 13, 13
    3. 14 NOVEMBER 13 NOVEMBER 20, 13
    4. 21 NOVEMBER 13 NOVEMBER 27, 13
    5. NOVEMBER 28, 13 4 DECEMBER 13

    December:

    1. 1ST DECEMBER 13 DECEMBER 4, 13
    2. 5 DECEMBER 13 DECEMBER 11, 13
    3. 12 DECEMBER 13 18 DECEMBER 13
    4. 19 DECEMBER 13 DECEMBER 25, 13
    5. 26 DECEMBER 13 DECEMBER 31, 13

    Why the "weeks" in November, have all 7 days, while the "weeks" in the first or the last week in the other month usually have less?  (For example, February 28 is a 'week' alone.)

    The following works for the other months:

    WITH all_days AS

    (

    SELECT DATE "2013-01-01' + LEVEL - AS a_date 1

    OF the double

    CONNECT BY LEVEL<=>

    )

    SELECT DISTINCT

    More GRAND (TRUNC (a_date + 4, 'IW') - 4)

    , TRUNC (a_date, 'MONTH')

    ) AS week_begin

    , The LEAST (TRUNC (a_date + 4, 'IW') + 2

    TRUNC (LAST_DAY (a_date))

    ), Week_end

    Of all_days

    ORDER BY week_begin

    ;

    Output:

    WEEK_BEGIN WEEK_END

    ----------- -----------

    January 1, 2013 January 2, 2013

    January 3, 2013 January 9, 2013

    January 10, 2013 January 16, 2013

    January 17, 2013 January 23, 2013

    January 24, 2013 January 30, 2013

    January 31, 2013 January 31, 2013

    February 1, 2013 February 6, 2013

    February 7, 2013 February 13, 2013

    February 14, 2013 February 20, 2013

    February 21, 2013 February 27, 2013

    February 28, 2013 February 28, 2013

    ...

    November 1, 2013 November 6, 2013

    November 7, 2013 November 13, 2013

    November 14, 2013 November 20, 2013

    November 21, 2013 November 27, 2013

    November 28, 2013 November 30, 2013

    December 1, 2013 December 4, 2013

    December 5, 2013 December 11, 2013

    December 12, 2013 December 18, 2013

    December 19, 2013 December 25, 2013

    26 December 2013 31 December 2013

Maybe you are looking for

  • firmware Acer iconia b1-710

    Hi all I'm looking for firmware download for my iconia b1 can someone help me because I'm stuck in boot loop tried hard reset and factory reset but no need to change firmware put on sd card.

  • I try to install Windos XP updated 6: KB951847, 79909 982168, 2518864, 2539631, 2418241.

    I keep trying to install 6 updates of the automatic update. KB951847, 79909 982168, 2518864, 2539631, 2418241 I download and install them as usual, but once installed, they re still appear FRO download and installation. It happened for about 1 week.

  • How to uninstall updater iq on vista

    There is this pop up on my screen that asks you to install updater iq on my computer. I don't want that, and I need help to remove it from my computer. There is also this boingo wifi. Please help me to get the measures to remove as well. Thank you.

  • signed a document but dc do not rename the file "document-signed.

    When I sign a document in dc is no longer renames the file "document - signed" as it did in x 1, I missed something?

  • The wait for the customization of the vm finish

    Hi, I am trying to find a way to wait for customization of vm finish before moving on to the next script. That's only 1 vm. I've seen a screenplay written by Lan Renouf, according to me, but I don't know how to change the script to look at the State