first day of the year and Monday next year

Hello all;

Given a year, how to determine the first day of this year and the next two Mondays for this year...

This gives a shot:

SELECT TRUNC(TO_DATE('2010','YYYY'),'YEAR')                        AS first_day_of_year
     , NEXT_DAY(TRUNC(TO_DATE('2010','YYYY'),'YEAR')-1,'MONDAY')   AS first_monday_of_year
     , NEXT_DAY(TRUNC(TO_DATE('2010','YYYY'),'YEAR')-1,'MONDAY')+7 AS second_monday_of_year
FROM   dual
;

Tags: Database

Similar Questions

  • 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 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 with the mobile and shatter proof - broken

    Hello

    I bought Xperia double Z3, mobile is great and every thing,

    In the first day of use, it fell out of my hand on the ground, I picked up there instantly, but I was surprised that the screen was kicked as he was struck by the big hammer!
    the functionality of contact has been lost, I went back to the buyer, and he told me that the warranty covers accidents, I told him that I had samsung s4 for two years and it is fell 100 times and harder than that and there was no damage at all to the screen!

    They said that the screen was not shock resistant break proof!

    I send the local support of sony in Egypt and they replied "good luck with your repair!

    How can a mobile screen get bashed like that from a simple fall, and what is the problem with people taking in charge of sony?

    Someone knows how to climb to a higher level of support?

    If there is, please share the link, there is no such thing as a "phone shatter proof". I'm sorry about your question, but you have 2 options, 1. with your Xperia local as Jean-Claude suggested or DIY 2, for the last dated, you will cancel your warranty, but it might be cheaper, just to buy the LCD screen online and follow this

    http://www.Xperiablog.NET/2014/09/30/Xperia-Z3-disassembly-Guide/

    https://www.YouTube.com/watch?v=9ZLLChEXzWk

  • How to extract the first day of the year quarter

    Hello

    How can I write a query to extract the first day in a neighborhood of declaration

    for example: -.

    Q1 starts from April 1 to June 30, second quarter starts from July 1 to September 30, third quarter starts from 1 October to 31 December and the fourth quarter begins from January 1 to March 31.

    How can I recover then the first day of these quarters, regardless of the year. The year can be any year.

    Hello

    don't know exactly what you want, but if you want the first day of a quarter for any given date and then

    select trunc(sysdate,'Q') from dual;
    

    Sysdate obviously could be a valid date.

    André

  • 1st day of the year then the Monday group

    Hello expert;

    I have the following tables below
    create table table_one
    (
     v_id varchar2(60),
     close_date date
    );
    insert into table_one
      (v_id, close_date)
    values
      ('A', to_date('1/1/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));   --- First day of the year
    
    insert into table_one
      (v_id, close_date)
    values
      ('B', to_date('1/4/2010 2:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));   -- monday
      
      insert into table_one
      (v_id, close_date)
    values
      ('C', to_date('1/11/2010 1:47:19 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  -- monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('5/6/2010 5:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  --- not a monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('E', to_date('5/3/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  ---monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('F', to_date('2/9/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  -- not monday
    I need to modify my query below and I can't think of a good way to go about it
    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD') from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    group by t.v_id, to_char(t.close_date, 'YYYY-MM-DD');  
      
    what I'm trying to do is in fact I want to group by only Mondays









    Edited by: user13328581 on Nov 17, 2010 8:04 AM
    
    Edited by: user13328581 on Nov 17, 2010 8:04 AM
    
    Edited by: user13328581 on Nov 17, 2010 8:29 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03
    

    If you also want the first day of the year that you mentioned.

    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    or  extract( month from t.close_date) + extract( day from t.close_date) = 2
    
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    A     2010-01-01
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03
    

    Published by: pollywog on November 17, 2010 11:38

  • 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 get the last day of the year

    Hi all

    Thanks in advance...

    How do I get the last day of the year that I'm passing date at run time.

    I can manage to get the first day of the year by
    SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
    of the double

    Thanks in advance

    Concerning
    Sachin
      1*  select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual
    SQL> /
    
    DD
    -----------
    31-DEC-2010
    
  • 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 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!

  • Deriving from the first day of the week ww in the year yyyy

    I need to be able to display the first day of a particular week in addition to the "week of the year" and the year. for example:
    select to_char("ServiceDate",'yyyy-ww') as "Year/Week", sum("Points") as "Points"
    from my_table
    group by to_char("ServiceDate",'yyyy-ww')
    order by to_char("ServiceDate",'yyyy-ww')
    give me the following:
    Year/Week     Points
    2008-33            1                      
    2008-35            1                      
    2008-42            4                      
    2008-43            2                      
    2009-01            1                      
    ...
    and so on. What I would like to add to the dataset is the same day, the first day of the week for this week/year. For example, the first line would look like this:
    Year/Week     1st day of week     Points
    2008-33          08-AUG-2008*         1
    * Or whatever the first day of the week 33 of 2008 is (assuming that "first day of the week" is a Sunday, in my case).

    My brain is on "dim" right now; any help is greatly appreciated.
    Thanks in advance,
    Carl
    select  to_char(trunc("ServiceDate",'ww'),'yyyy-ww') as "Year/Week",
            to_char(trunc("ServiceDate",'ww'),'DD-MON-YYYY') "Week Start Date",
            sum("Points") as "Points"
    from my_table
    group by trunc("ServiceDate",'ww')
    order by trunc("ServiceDate",'ww')
    /
    

    SY.

  • calculate the time in seconds, the day of the year and year

    I have a data file where they record three columns, the seconds elapsed since midnight, day of the year and the year.  I am creating a timestamp of LabVIEW from these three numbers.  Of seconds elapsed since midnight, I can create seconds, minutes and hours.  If I feed in a cluster of time with the day of the year and the year, the timestamp of output is 0.  Does not work.  Although an input of the day of the year element, the Date and time with seconds function apparently requires day for months and months to work.

    The only solution I can imagine at this stage is to calculate the month and the day of the day of the year, which would imply a choice of the month table and a check of the leap year.

    Smart solutions, I'm missing?

    DaveT

    Dave,

    I found a Julian Georgian so far.

  • Why my laptop wireless computer connect to the internet first thing in the morning and late at night, but not during the day.

    I wonder if you can help me please?

    I have problems with my satellite internet access on my laptop wireless.  He beautifully connects to the router and the signal is excellent. However, I'm unable to connect to the internet.  I can use the laptop first thing in the morning because it connects right away, but I would say that 95% of the day I can't use it at all.  Sometimes it will work later in the evening.  I learned this could be due to the intensity of the signal and that some suppliers to fall during the day.  My desk top connects perfectly (if the weather permits it) but is not on the wireless network.  I had no problem with my laptop when I used my previous service provider.  It becomes more frustrating that the inability to use the internet visited my lap top unnecessary.  I can't use it on my neighbors wireless network no problem at all but they we internet different provider.  Can you please help because I don't know why it works first thing in the morning and sometimes late at night, but not during the day?  No matter where the lap top is the first thing in the morning, it will work even if it is forty feet away.  I can sit during the day with my phone right by my router and it still not connect to internet even though the router signal strength is excellent and desktop is on the internet.  Any help would be great, because it leads me into the wall!  I am using WIndows 7 on my lap top from acer.

    Kind regards

    Julie

    I would like to thank everyone for their help with my question.  I can tell you now that I have it solved and I'm pretty embarrassed to say the least.  Following a change of internet service provider, I put a cable into the wrong port on the router... silly me!  It works perfectly now. Thank you once again.

  • Why Windows 8 'Calendar' app has no option to change the first day of the week?

    Why can't I change the first day of the week in 'Calendar' app?

    Hi Andriamparany,

    Windows calendar - like some other ' standard' Windows 8 applications - is pretty basic and was obviously designed to speed up tasks 'on the fly'. As soon as it comes to advanced settings for these applications, you will need to upgrade to the "long" version

    A good example is changing the 1st day of week / time of starting the day... To do this, you must go to http://Outlook.com (what I called the "expanded version" of Windows 8 Mail, calendar, people... APSS). So, from your browser preferred:

    • Open http://Outlook.com and enter your address email + password if necessary
      ==> By default, it displays your emails
    • Click the arrow to the bottom of the Panel that is located next to Outlook - upper left corner of the page
      ==> This shows 4 tiles: Mail, people, calendar and SkyDrive
    • Click on the calendar tile
      ==> That displays your calendar
    • Click the Options - just before a blue ? - link in the upper right of the screen

    Don't forget to save your changes when you have finished...

    Hope that answers & help

    See you soon

    LZ.

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

Maybe you are looking for