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

Tags: Database

Similar Questions

  • 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>
    
  • 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;

  • 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

  • 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;
    
  • 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!

  • each first day of the month

    Hi friends here is the querry I wrote to display every first day of the month, but there is something wrong in it... Help me...
    create or replace procedure minmax is
    cursor minmax_cur is
    Select min (hiredate), max in emp (hiredate);
    number of v_minmonths;
    number of v_maxmonths;
    number of v_minyears;
    number of v_maxyears;
    x date of publication;
    date of y;

    Start
    Open minmax_cur;
    extraction minmax_cur
    x, y;
    v_minmonths: = extraction (x months);
    v_minyears: = extraction (year x);
    While (x, y) loop
    because me in 1... v_minmonths loop
    If (v_minmonths < 12) then
    v_minmonths: = v_minmonths + 1;
    x: = x + 28.
    dbms_output.put_line(v_minmonths ||) '/' || '01'. '/' ||
    v_minyears);
    on the other
    v_minmonths: = 0;
    v_minyears: = v_minyears + 1;
    x: = x + 28.

    end if;
    end loop;
    end loop;
    minMax end;
    and the results are

    01/01/1981
    01/02/1981
    01/03/1981
    ..................
    .........---
    01/04/1987
    01/05/1987
    01/06/1987
    01/07/1987
    01/08/1987
    01/09/1987
    01/10/1987
    01/11/1987 the problem is max (hiredate) is 5/23/1987...it must show up to 01/05/1987...
    I get a few more months...
  • 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

  • Function to retrieve the first day of the month.

    Select (sysdate, 'IW') of double

    I know it takes the date of Monday. Is there a function like above that has the date of return to the first Monday of the month?

    Thanks in advance.

    Hello

    NEXT_DAY is very convenient, but it is dependent on the NLS_DATE_LANGUAGE, and you cannot pass an argument to override that.
    TRUNC (dt, 'IW') is not in the NLS settings, then you may prefer this:

    TRUNC ( 6 + TRUNC (SYSDATE, 'MONTH')
          , 'IW'
          )          AS first_monday
    

    1st Monday of the month is fixed to the Monday or before the 7th of the month.

  • Get the last day of the month

    Hello

    How can I get the (day number of the) last day of a given month and year?

    So, if

    year 2015 = and month = 1, the output should be 31

    year = 2012 and month = 2 while production is expected to be 29

    year 2013 = and month = 2 while production is expected to be 28

    etc.

    Y at - it no OBIEE to achieve? If not, then a command SQL Oracle is very good too (I prefer OBIEE however)

    Thanks in advance,

    Erik

    You start from the first day of the month, you add 1 month [TIMESTAMPADD (SQL_TSI_MONTH, 1, 'your date')], you must subtract 1 day [TIMESTAMPADD (SQL_TSI_DAY,-1, 'your date')] and use the DAYOFMONTH function to get the number of the last day of the month [DAYOFMONTH ('your ' date')].

    All these calls nesting together and you're there.

  • Today date (first and last) last month

    Hello

    I need to calculate the first day of the month last accounding to the sysdate as below

    (01.05.2012' 00:00 ')

    I need to calculate the last day of the month last accounding to the sysdate as below

    ('31.05.2012 23:59 ')

    Thank you
    trunc (sysdate, 'mm')
    trunc (add_months (sysdate, 1), 'mm') - interval '1' second
    

    (not tested, no database handy)

  • How can I update the column 1st day of each month

    Hello
    I have an Emp table with the following columns
    1.Emp_name varchar2(50),
    2.Days number(3).
    now it has the following features,
    Emp_name              Days
    Mishra                     11
    David                      15
    Raju                       18
    Now I need to update the column 'Days' 20 for emp_name all whenever the date is the first day of the month
    IE June 1, 2012 July 1, 2012 and so on.
    How can we do?
    can someone help me.
    Thank you.

    Look for the DBMS_SCHEDULER package.

    Kind regards

  • 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.

  • 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

Maybe you are looking for

  • Satellite C645-SP4131L - video card update possible?

    Hi, I hope that this question is not repeated, I'm looking for the forum but not found a solution to my problem. Search online for information on my toshiba are capable of graphics card, ATI or another, and if so, what models are compatible?I hope no

  • Cannot open the search result in Safari or Chrome

    Since I upgraded my iPad to iOS 9.3 2 Air, I can't open search results in Safari or Google Chrome. I tried to erase the data of web browsing and I tested various engines (Google, Yahoo and Bing). When I search something all results appear, but when I

  • How do I see wich version of Skype that I use?

    In the past two days ive been receiving ads on "you have the latest version of Skype" and I don't really know how to find out

  • Qosmio G30 - 190 can't start

    I have the Qosmio G30 - 190 model No computer. PQG30E-039023FR There is often a blue if poster tell me there's an erros on the systemI tried to restore from the TOSHIBA restore CD. but after you create the software image and eject the recovery CD, th

  • error 7 - files not in the spaces provided

    Hello The software in question worked until yesterday morning, how he would generate a 7 (file not found) error when it starts up. (Also completely functional) backup software generates the same error, like the VI another who needs a couple of the sa