How to reach school year from a date

How to get the academic year to date? (7/1/year-6/30/year)?

Thank you
There,

Hello

Try this:

with t as
(
select date '2012-06-29' d1 from dual union all
select date '2012-06-30' from dual union all
select date '2012-07-01' from dual union all
select date '2012-12-31' from dual union all
select date '2013-01-29' from dual
)

select
     d1
     ,case when to_char(d1, 'mm') <= '06' then to_char(add_months(d1,-12),'yyyy') || '-' || to_char(d1,'yyyy')
                    else to_char(d1,'yyyy') || '-' ||to_char(add_months(d1, 12),'yyyy')
                    end     ac_year
from
     t

D1        AC_YEAR
--------- ---------
29-JUN-12 2011-2012
30-JUN-12 2011-2012
01-JUL-12 2012-2013
31-DEC-12 2012-2013
29-JAN-13 2012-2013 

;

Kind regards

Peter

Tags: Database

Similar Questions

  • How can I move photos from one date to another in my catalog? Downloaded LR of photos taken over several days to a date. LR6 PC Win7

    How can I move photos from one date to another in my catalog? Downloaded LR of photos taken over several days to a date. LR6 Win7 PC.

    Hi bubba43,

    Please select the images in the library grid mode Module and then drag and drop them in another folder you want.

    Kind regards

    Tanuj

  • How to eliminate messages sent from unwanted data - Message-ID:-User-Agent:-MIME-Version:?

    When I send to myself, the data messages sent both folders Inbox.
    Sometimes as Content-Type: x-store-info & several other x-Details: In-Reply-To: Return-Path:
    Maybe it's a virus that has fully updated AVG Free scan maximum does not detect.

    View | Headers | Normal. I think that yours is set to "All".

  • How to restore an application from a date longer than Time Machine?

    Hello!   I had to throw my old Firefox browser.   Something was wrong in the middle of an upgrade and it broke.   Rather than download a new copy on the net, is anyway that I can go in my Time Capsule via my Time Machine to restore?  This way I can get all my settings and bookmarks.  It would save me a lot of time!  Or is this kind of thing not stored in Time Machine?   I went back a few days and could not find Firefox in applications.  It was like she didn't show what I have now.   Any suggestions?  Thank you.

    This way I can get all my settings and bookmarks.

    Mac OS X is a multi-user system. The user files are stored in separate directories for system files. System files are not changed by your settings that apply to them in system folders, your settings are stored in preferences files in your own user ID.

    Feel free to re - download or restore from backup any version of Firefox that you like. But their preferences are in your own ID user, not in Applications. Download a new version does not change your settings at all.

  • Subtract 5 years from date

    How to subtract 5 years from the next part of the code?

    Anthony

    I made myself:

    DateFormat (DateAdd ("yyyy", "-5", now())), "yyyy, mm, dd")

    Thanks if

  • How to operate my function from PL/SQL?

    I have 4 table

    1st is EMPLOYEE (E #, ENAME), the primary key is E #.

    2nd is DRIVER(E#,L#), the primary key is E # ID EMPLOYEE

    3. is TRIP(T#,L#), the primary key is T #, foreign key L # driver

    4th is the primary key TRIPPT(T#,PT#) T # travel

    I create a function that finds the length (total number of pt #) of the longest point to the driver
    create or replace function LONGPT (DL# in TRIP.L#%type)
       return TRIPPT.PT#%type
    IS
       TRIPPT#   TRIPPT.PT#%type;
    begin
       select max (PT#)
         into TRIPPT# 
         from TRIPPT
        where T# in (select T#
                       from TRIP
                      where L# = DL#);
    
       return nvl (TRIPPT#, 0);
    end LONGPT;
    / 
    How can I do a select query to view the employee NAME, LONGPT. The name of the driver that perform no trigger point must be in the application as well.

    I try
     
    SELECT DRIVER.L# AS License_No, LONGTPT(TRIP.L#) AS "LONGEST POINT" 
    FROM DRIVER 
       LEFT OUTER JOIN TRIP on DRIVER.L# = TRIP.L#;
    This only query the L# and the LONGEST Point.
    Could someone guide me how to do select on screen the ENAME and with my LONGPT function.

    Published by: user4757127 on November 25, 2012 10:11

    Published by: user4757127 on November 25, 2012 10:17

    Published by: user4757127 on November 25, 2012 10:18

    Hello

    Welcome to the forum!

    user4757127 wrote:
    ... How can I do a select query to view the employee NAME, LONGPT. The name of the driver that perform no trigger point must be in the application as well.

    I don't know what you mean by "the employee, LONGPT.

    My best guess is that you need join the employee table in your current query:

    SELECT  driver.l#          AS License_No
    ,     employee.ename                              -- *****  NEW  *****
    ,     longtpt (trip.l#)      AS "LONGEST POINT"
    FROM           driver
    JOIN          employee     ON   driver.e#     = employee.e#     -- *****  NEW  *****
    LEFT OUTER JOIN trip          ON   driver.l#     = trip.l#
    ;
    

    Again, this is just a guess and guess isn't always the best way to solve problems.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • How to replace a "null" in the date field to zero

    Hi guys,.

    I'm a lil stuck with this problem.
    I have a requirement where I need to replace a null value in the date field to zero.
    For example,.

    Cancel_date Cancel_date
    20120301 20120301
    20120908 20120908
    value null-> > > > > 0


    Thank you
    Anita

    Hi, Anita,.

    0 is not a DATE, so you cannot view it in a DATE column.
    There is no '0' display problem in a VARCHAR2 column, so use TO_CHAR to display dates, even if the default format, it's exactly what you want.

    SELECT     NVL ( TO_CHAR (date_column, 'YYYYMMDD')
             , '0'             -- or '       0', if you want it right-justified
             )          AS date_string
    FROM     table_x
    ;
    

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • How to find the difference between two dates in time except Sunday

    Hi all

    I have a table, as shown below.
    SQL> select * from test;
    
    TR_ID                                              CREATE_TIME                                                                       CODE
    -------------------------------------------------- --------------------------------------------------------------------------- ----------
    S12341                                             05-JUN-12 12.20.52.403000 AM                                                      1003
    S12342                                             11-JUN-12 11.15.33.182000 AM                                                      1003
    S12342                                             07-JUN-12 12.00.36.573000 PM                                                      1002
    S12343                                             20-JUN-12 12.34.37.102000 AM                                                      1003
    S12343                                             15-JUN-12 11.34.27.141000 PM                                                      1002
    S12344                                             01-JUL-12 10.01.06.657000 PM                                                      1002
    S12344                                             06-JUL-12 12.01.04.188000 AM                                                      1003
    S12341                                             31-MAY-12 11.20.38.529000 PM                                                      1002
    I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.

    For example:

    TR_ID: S12344
    1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
    1003_Create_time: 12.01.04.188000 AM 6 July 12

    1002 create time is 22:00 Sunday.

    If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.

    I tried the sub query after doing a search on this forum but I am not getting the desired output.
    SELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and 
    ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) 
    from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d 
    WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
    Need help to get the desired o/p

    Hello

    If I unederstand the problem correctly, that's what you want:

    WITH       got_extrema     AS
    (
         SELECT       tr_id
         ,       CAST (MIN (create_time) AS DATE)     AS start_date
         ,       CAST (MAX (create_time) AS DATE)     AS end_date
         FROM       test
         GROUP BY  tr_id
    )
    SELECT       tr_id
    ,       start_date, end_date          -- If wanted
    ,       24 * ( ( ( TRUNC (end_date,   'IW')          -- Count -1 day for every full week
                        - TRUNC (start_date, 'IW')
                 )
               / -7
                  )
                + LEAST ( end_date               -- If end_date is a Sunday
                            , TRUNC (end_date, 'IW') + 6     -- consider it 00:00:00 on Sunday
                     )
                - CASE
                          WHEN  start_date >= TRUNC (start_date, 'IW') + 6     -- If start_date is a Sunday
                   THEN  TRUNC (start_date, 'IW') + 6               -- consider it 00:00:00 Sunday
                   ELSE  start_date
                      END
                )     AS total_hours
    FROM      got_extrema
    ;
    

    I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.

    Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
    (a) 1 day is deducted for each week between start_date and end_date
    (b) if End_date is a Sunday, none of the end_date himself hours are counted
    (c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.

    TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.

    Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
    Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
    Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • How to create an automatic text field - has a date of three years from the current date?

    I'm trying to create a PDF form that is automatically entered a three-year expiration date in the future of the current date in a created text field.

    Text field name: ExpDate

    Text field format: mm/dd/yy

    So far, I entered in the following in the Page Properties-> Actions-> Add Action (trigger = Open Page, Action = run a JavaScript script):

    var ExpDate = new Date();

    ExpDate.setYear (ExpDate.getYear () + 3);

    var f = this.getField ("ExpDate");

    f.Value = util.printd ("mm/dd/yy", ExpDate);

    We will attend the correct expiration date the day where I do the certificate (i.e. There will be 07/06/16, June 7, 2016), but when I open it the next day will be always ready 07/06/16 instead of 06/08/16. I'm sure it is something simple that I need to change. Any ideas?

    If she says ' 07/06/16"on 7 June 2016, which means that it does not work properly, either, as it does not add 3 years to the date of the day... It should show ' 07/06/19.

    You see error messages in the console (Ctrl + J) JS when you open the file?

  • How can I create a chart that creates new series each year when the data are not collected on a daily basis?

    I collect numbers "occasionally" of my solar system and to create a standardized chart that shows that the generation on an annual basis, so I can compare fall in the fall of each year, etc..

    Because the information is not strictly 'daily' (just whenever I get to it), I don't know how it normalize for several years.

    For example, if I had

    Date - Kw/day

    15/01/10 - 14

    03/04/10 - 18

    18/04/10 - 17

    01/06/10 - 19

    21/09/10 - 15

    03/12/10 - 9

    07/02/11 - 13

    02/05/11 - 16

    17/08/11 - 18

    01/11/11 - 12

    02/11/11 - 12

    05/01/12 - 9

    04/06/12 - 12

    and so on.

    What I'd like to see is a line graph for each year from January to December with these datapoints on it. I have much more "incremental data" that I presented above, but it's on "random dates" during the last 8 years, and I'm just trying to see how each year compared to other years.

    To be at the front, I tried to understand how this in Excel as well, but he could not understand where the other.

    DRM for any tips/tricks/tips!

    Steve

    This might work for you...

    I placed your data in a table named "Data."

    Create a second (in this example, titled 'Table 1')

    In the table 'Table 1' months are in the first column and the first row (which is a header row) contains the years - add columns to add new year:

    B2 = if (SUMIFS (data: $B, data: $A, "> =" & (B$ 1, $A2, 1), DATE data: $A, "<" & EOMONTH(A1,0) will GET (DATE B$ 1, $A2, 1, 0) "" "") > 0, SUMIFS (data: $B, given: $A, "> =" & (B$ 1, $A2, 1), DATE data: $A, "<" & EOMONTH(A1,0) will GET (DATE B$ 1, $A2, 1, 0) "" ""), "")

    It's abbreviation dethrone select cell B2 and type (or copy and paste it here) the formula:

    = IF (SUMIFS (data: $B, data: $A, "> =" & (B$ 1, $A2, 1), DATE data: $A, "<" & EOMONTH(A1,0) will GET (DATE B$ 1, $A2, 1, 0) "" "") > 0, SUMIFS (data: $B, given: $A, "> =" & (B$ 1, $A2, 1), DATE data: $A, "<" & EOMONTH(A1,0) will GET (DATE B$ 1, $A2, 1, 0) "" ""), "")

    Select copy of cell B2

    Select the cells B2 at the end of F13, dough

    now select cells A2 through F13 and add a graphic (the XY scatter diagram)

    Add new year add one (or more) new columns for "table 1", then add the year to the top:

    Now alone, click the chart to activate the chart.  then click on the button 'change data references '.

    now, drag the data reference control handle to the right to add the new year to the table:

    You can add several years to the time, so you don't have to it very often

  • I bought a new iPhone SE. My iCloud account still shows my old iPhone data use. How can I erase it from my ICloud account?

    I bought a new iPhone SE. My iCloud account still shows my old iPhone data use. How can I erase it from my ICloud account?

    Do you mean that you see your old data use on the new iPhone?

    Go to settings > cellular > [scroll down to] Reset Statistics

    Otherwise, where exactly do you see this use?

  • How to reach individual Contact data to Mac mail

    How to reach individual Contact data to Mac mail

    In Contacts, you can export a VCard Contact, and then attach to an e-mail message

  • How to access and recover photos and data from icloud?

    How to access and recover photos and data from icloud?

    Sign up for settings/iCloud and turn on the various switches in sync. On a computer, go to system/iCloud Preferences, log in and check the different items to synchronize.

  • How to get my serial number lost? I bought my Adobe Creative Suite years from a retailer. This is an installation CD.

    How to get my serial number lost? I bought my Adobe Creative Suite years from a retailer. This is an installation CD.

    Janneh82309070, I looked at the e-mail address you sent me via private message and there is no Adobe software titles registered under this account.  By the document referenced by Ned in the message #1 this discussion, please contact our support team directly at contact customer service if you are unable to locate your serial number.  You want to be prepared with any other e-mail addresses or telephone numbers that may have been used to record the Creative Suite 4.  If the software title was never registered then Adobe will not have a record of the serial number.

    I apologise for the difficulties you have find your serial number Janneh82309070.  Future versions of the Creative Suite registration was automatic to help reduce this type of events.

  • Year (only) extracted from field Date and display in the text field

    I need extract the year from a field of date entered by the user and display the year in a text field. Can someone help me with the correct script to do this?

    Hello

    It is quite easy to achieve with FormCalc.

    In you the output of the date fields event add the following code:

    textField1 = Num2Date( Date2Num($.formattedValue, "MM/DD/YYYY"), "YYYY")
    

    Note: This example assumes that your date field formats the date with "MM/DD/YYYY". You may need to change the schema to make it work for your purpose.

Maybe you are looking for