Choose the date of the table

Hello

It comes to my table
CREATE TABLE TEMP_LEAP
  (
    "DATE_FROM" DATE
  )
Insertion of the data in it with the procedure which takes 2 parameters of date format:
CREATE OR REPLACE
PROCEDURE  "T_PROC" (p_dat_from date, p_dat_to date) IS
BEGIN


DECLARE

  day       number     := 0;
  st           NUMBER := 0;

BEGIN

day := p_dat_to+1 - p_dat_from; 

for p in 1 .. day     
           
loop   
                
   insert into temp_leapp (date_from) values (p_dat_from+st);    
                
    st := st+1;  
              
end loop;  
           
 commit; 
END;
END;
Now lets fill in the data in the table:
execute T_PROC(TO_DATE('01.01.2010','DD.MM.YYYY'),TO_DATE('17.08.2013','DD.MM.YYYY'));
Data are now filled in the table.

I want to do is do a select statement that will make the following output data:
01.01.2010 - 31.12.2011
01.01.2012 - 31.12.2012
01.01.2013 - 17.08.2013
I want is to get the leap year if there is a. I only need of days in the year, so don't mind the months.

I need to check if there is a leap year in considering the p_dat_from and p_dat_to.

If it isn't then you will get a single record of our instruction select and values will be made of: p_dat_from - p_dat_to.

If there is a leap year in our period we will arrive after statements (example above).

01.01.2010 - 31.12.2011 <-first date is p_dat_from and second is the last day before the leap year
01.01.2012 - 31.12.2012 <-this is leap year. First date is the beginning of the leap year and the last date is the end of the leap year or p_date_to (if it ends in leap years).
01.01.2013 - 17.08.2013 <- and this is the period after the leap years.

It is a piece of code that I fell or with up to now:
SELECT
MIN(date_from),
MAX(date_from)
FROM temp_leap
WHERE remainder(to_number(to_char(date_from,'yyyy')),4) = 0
union

SELECT 

MIN(date_from) over (partition by to_char(date_from,'yyyy')),
MAX(date_from) OVER (PARTITION BY to_char(date_from,'yyyy'))
FROM temp_leap
WHERE remainder(to_number(to_char(date_from,'yyyy')),4) <> 0

ORDER BY 1,2;
OK, that's all. I hope that its understandable that I do.
If you have a questions please ask away.

PS is there anything I need to do. You don't have to bother with the questions "what i February is after before etc." I don't love about it. All the other logic is already fixed all I need is what I wrote above.

Thank you.

Published by: BluShadow on March 14, 2013 08:24
Fixed barcode labels

Here's a way...

SQL> create table temp_leap(date_from DATE)
  2  /

Table created.

SQL>
SQL> insert into temp_leap
  2  select date '2010-01-01' + rownum - 1
  3  from dual
  4  connect by rownum <= (date '2013-08-17' - date '2010-01-01') + 1
  5  /

1325 rows created.

SQL>
SQL> commit
  2  /

Commit complete.

SQL> ed
Wrote file afiedt.buf

  1  select min(date_from)||' - '||max(date_from)
  2  from
  3        (select date_from
  4              ,sum(leap_yr_switch) over (order by date_from) as leap_yr_switch_cnt
  5        from (
  6              select date_from
  7                    ,case when lag(leap_yr) over (order by date_from) != leap_yr then 1 else 0 end as leap_yr_switch
  8              from (
  9                    select date_from
 10                          ,case when mod(to_number(to_char(date_from,'YYYY')),400) = 0
 11                                 or (    mod(to_number(to_char(date_from,'YYYY')),4) = 0
 12                                     and mod(to_number(to_char(date_from,'YYYY')),100) != 0
 13                                    )
 14                           then 1 else 0 end as leap_yr
 15                    from temp_leap
 16                   )
 17             )
 18       )
 19  group by leap_yr_switch_cnt
 20* order by min(date_from)
SQL> /

MIN(DATE_FROM)||'-'||MAX(DATE_FROM)
-------------------------------------------
01-JAN-2010 00:00:00 - 31-DEC-2011 00:00:00
01-JAN-2012 00:00:00 - 31-DEC-2012 00:00:00
01-JAN-2013 00:00:00 - 17-AUG-2013 00:00:00

Published by: BluShadow on March 14, 2013 08:51
a slight correction in the calculation of the leap year, forgotten 100 years being does not leap.

Tags: Database

Similar Questions

  • Form check synchronize on Popup to the selected record from the table

    I'm trying to recreate what I did on the portals of the OAS in Weblogic/ADF. I have JDeveloper 11.1.1.2.0. What I do seems to be a little different than the tutorials: I need something like the tutorial master-detail, but instead the details appearing on the same page, it should appear in a popup. I managed to build the part table/popup. But when the popup appears, it displays the wrong record. Here are the steps I used to create this page:

    After you create the ADF Fusion Middleware project:

    1 create templates for the tables I need.
    2. create the JSF Page.
    3 drop panelCollection on the page.
    4. remove my data to see in panelCollection control and choose the Table read-only ADF. Select the sorting and selection options.
    5 change table properties: selected = DisplayRow, EditingMode = clickToEdit
    6 drag the Popup on the page.
    7. remove my data from view in popup control and choose the form of the ADF. Select the send option.
    8 drop showPopupBehavior on the page. Name of the popup. The value triggerType to the 'selection '. (triggerType "click" works, too)
    9 deploy.

    The table is displayed. I click on a line. The pop-up window appears. The form of popup displays the first record in the table. I click on any line.

    I just bought the merger Oracle 11g Developer Guide, but were not able to answer this question yet.

    Any ideas?

    Thank you.

    See this video for how it works for me:
    http://www.ScreenToaster.com/watch/stWUtcRkVLQ1BcSV1aX15Q

  • easily the value column in the row of the table when you click check box

    Hello

    in Jdev 11.1.2.3 I have a table which line is made up of 2 columns:
    How can I set value #{securityContext.userName} for it1 in column 2 when soc1 is amended in column 1?
    I can see how to set < af:setPropertyListener soc, then find currentRow in sib and set the respective attribute in VO.
    Can someone suggest an easier approach, a shortcut to one upstairs? In my view, there are some... :-)
    Use a clientListener?

    < af:column sortProperty = "#{bindings." V1.hints.selected.name}"sortable ="false ".
    headerText = "" id = "c1" width = "30" > "
    < af:selectBooleanCheckbox value = "#{row.bindings.Selected.inputValue} '"
    label = "#{row." Bindings.Selected.label}.
    shortDesc = "#{bindings." V1.hints.selected.ToolTip}"id ="sbc1"/ >
    < / af:column >

    < af:column headerText = "#{bindings." V1.hints.ProcessedUser.label}"id ="17">
    < af:inputText value = "#{row.bindings.ProcessedUser.inputValue}"it1 "
    < / af:column >

    Hello

    is easier to

    1. open the Pagedef
    2 create a new attribute value binding in the bindings section
    3. choose the table iterator
    4. mark the attribute for the second column and OK it
    5. in the setPropertyListener, you can now pass the value as #{bindings.. inputValue}

    Frank

  • Minor emergency - copy of the table of contents

    Hi guys,.

    What a day for having a panic... hope there are a few other fine individuals out there work and looking for a way to earn their Badge to act good Christmas...

    OK, so I think it's really simple. I am currently a table of contents for a customer who wants only parts of the information contained in our webhelp, but I'd like any first of the generic TOC. I was stupid (very, very possible) or is there no easy way to make a table of contents based on one that already exists? I can drag and drop the files in project in the project manager, but they are not organised brilliantly and it would take much more time to make sure they were all in the right place...

    Does anyone know a quick fix to this?

    Thanks in advance if anyone can help...

    Hello

    If you use RoboHelp HTML 7 or 8, you can easily copy a table of contents in the table of contents Editor.

    First, open the pod of table of contents Editor. Then click on the button create a table of contents in the toolbar of the OCD pod.

    From there, click on new and place a check mark in the check box to copy the Table of contents by existing.

    Type a name for the new table of contents and choose the table of contents to copy and you should be good to go.

    See you soon... Rick

    Useful and practical links

    Wish to RoboHelp form/Bug report form

    Begin to learn RoboHelp HTML 7 or 8 times now - $24.95!

    Adobe Certified RoboHelp HTML Training

    SorcererStone blog

    RoboHelp EBooks

  • How do you choose the data in tables using EBS web page?

    Hi friends,


    I'm in the URLs of the web pages EBS 11i > http://vision.abc.com:8000.
    using the SA account.

    Is there a counter part based on web module/menu to display the data in the table?

    As
    Select * from fnd_tables;
    or
    Select * from po_vendors;

    something like that which allow the display of data


    Thank you very much

    Yes, but I want a web tool that uses the URL, not the client server those. :), which are not allowed by the security check.

    As a development tools, I believe that developer SQL and TOAD (in addition to SQL * more) are what you need (although these are client/server tools).

    Oracle Enterprise Manager is a good tool tracking (but not for development), as a DBA you use EM, and access it via a URL.

    I might not necessarily use sqlplus command. but a program stored as programs simultaneous fnd.

    There is no standard concurrent requests that can help achieve this goal.

  • Shared variable data type: can I choose a picture of a typedef custom, without making the table itself a typedef?

    Hi all

    I would like to pass a table to a cluster on my network. My group is typedef'ed, but I would avoid to pollute my project with an another redundant typedef.

    Is it possible to use the option "From Custom Control... ' of the shared variable with an array without saving the table as a new .ctl file?

    Oh, I didn't know you were using shared variables. I thought that you were just considered another option with TCP/IP or UDP or something like that. In this case, you will need to create a second custom control. This control would be a table with the cluster of typedef in there. Not need to make this new control itself a typedef however. Sorry, I know you were hoping for a different answer. I doubt a single file will really be "clutter" your project well

  • Dynamic calculation of the number of days between two dates in a table

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    Hi BO123,

    BO123 wrote:

    Hello

    I'm working on request where I dynamically calculate the number of days between two dates in a table.

    The calculation must be dynamic, i.e., when I recover the Start_date and End_date and move to the field following (call_duration) in the same row, the difference must be calculated dynamically in this area and make sure the field read-only.

    APEX version: 5.0

    one of the way to do this by calling ajax on change of end_date.

    See the sample code given below to fetch the resulting duration and making the field read only after calculation

    Step 1: Change your page

    under CSS-> Inline, put the code below

    .row_item_disabled {
      cursor: default;
      opacity: 0.5;
      filter: alpha(opacity=50);
      pointer-events: none;
    }
    

    Step 2: Create on demand Ajax process I say CALC_DURATION

    Please check Procces Ajax, see line 6.7 How to assign a value to the variable sent by ajax call

    Declare
      p_start_date  date;
      p_end_date    date;
      p_duration number;
    Begin
      p_start_date  := to_date(apex_application.g_x01);
      p_end_date    := to_date(apex_application.g_x02);
    
       --do your calculation and assign the output to the variable p_duration
      select p_end_date - p_start_date into p_duration
        from dual;
    
      -- return calculated duration
      sys.htp.p(p_duration);
    End;
    

    Step 3: Create the javascript function

    Change your page-> the function and the declaration of the Global Variable-> put the javascript function

    You must extract the rowid in the first place, for which you want to set the time, see line 2

    assuming f06, f07 and f08 is the id of the start date, and end date columns respectively, and duration

    See no line no 8 how set the value returned by the process of ajax at the duration column

    Replace your column to the respective column identifiers in the code below

    function f_calulate_duration(pThis) {
      var row_id  = pThis.id.substr(4);
      var start_date = $('#f06_'+row_id).val();
      apex.server.process ( "CALC_DURATION", {
      x01: start_date,x02: $(pThis).val()
    }, { success: function( pData ) {
    // set duration to duration column
    $('#f08_'+row_id).val(pData);
    // disable duration column
    $("#f08_" + row_id).attr("readonly", true).addClass('row_item_disabled'); }
    });
    }
    

    Step 4: choose the end date call the javascript function

    Go to report attributes-> edit your Date column end-> column-> Attrbiutes element attributes-> put the code below

    onchange="javascript:f_calulate_duration(this);"
    


    hope this helps you,

    Kind regards

    Jitendra

  • We can validate data while charging in the table from excel?

    Hello world

    My version of DB is

    BANNER                                                        
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production                          
    CORE 10.2.0.1.0 Production                                        
    TNS for Linux: Version 10.2.0.1.0 - Production                  
    NLSRTL Version 10.2.0.1.0 - Production  
    
    

    I have a task to create an automated script to load since excellent data into table with all the necessary validation.

    Is it possible to do? Suppose that the value of a column is '2ascsde', I need to take the first number and insert into the table.

    Some cases, we have Yes and no, instead, I just need to convert these values true and false, respectively. Please suggest something.

    Kind regards

    BS2012.

    How you fail to read data from Excel?

    Re: 5 How to read or write an Excel file?

    According to the method that you choose to do so, will determine what options you have for the handling and validation data.

  • Select this OPTION to generate XML data from the table using XMLELEMENT, XMLAGG gives error ORA-19011 string buffer too small

    My select statement fails with the error:


    The ORA-19011 string buffer too small


    The select statement looks like:


    SELECT TO_CLOB)

    XMLELEMENT ("accounts",

    XMLELEMENT ("count",

    XMLATTRIBUTES)

    rownum AS "recordId."

    To_date('20130520','YYYYMMDD') AS "datestarted."

    123456 AS "previousBatchId."

    56789 AS 'previousRecordId '.

    ),

    ....

    .... .

    .....

    XMLFOREST)

    SIG_ROLE AS "SignatoryRole."

    To_char(TRANSFER_DATE,'YYYY-mm-DD') AS "TransferDate."

    NVL(Reason,0) AS 'reason '.

    ) AS the 'transfer '.

    )

    ()) AS CRDTRPT

    OF ANY_TABLE;

    • It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    I'd use the XMLGEN package. But the environment team says no mounted drives in the future with the arrival of the EXADATA.

    NO HARD DRIVE MOUNTED, NO ACCESS TO THE DATABASE DIRECTORIES

    No UTL_FILE

    I need to use the REEL spool the resulting XML data of the SELECT query.

    SQL is a standard in my org, but I can do with a PL/SQL solution also to load data into a table (cannot use a COIL with PL/SQL)

    What I do is:

    1. a column of type CLOB to a xml_report of the loading of the above SELECT query table
    2. Then using SELECT * FROM xml_report to SPOOL the data to a file report.xml

    No need of XMLTYPE data behind. Xml data stream is fine for me.

    In addition, I need to validate the XML file, also using XSD.

    Problem is that the resulting lines of the select query are supposed to be from 15000 to 20000 bytes long.

    Oracle database version: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    A Suggestion or a solution to this problem would be appreciated.

    (Sorry for the use of "BOLD", just to make it more readable and highlight the imp points)

    Bravo!

    Rahul

    It looks like I can choose only 4000 characters using the SELECT statement (please, correct me if I'm wrong)

    You use the right method.

    There is an implicit conversion from XMLType to the data type VARCHAR2 as expected by the function TO_CLOB, where the limitation, and the error.

    To serialize XMLType to CLOB, use the XMLSerialize function:

    SELECT XMLSerialize (DOCUMENT

    XMLELEMENT ("accounts",

    ...

    )

    )

    OF ANY_TABLE;

    For the rest of the requirement, I wish you good luck trying to spool the XML correctly.

    You may need to play around with the SET LONG and SET LONGCHUNKSIZE commands to operate.

  • GR 11, 2 Data Pump. Import the table in a schema into another schema

    I have oracle stady. I export shema HR in the hrexport.dmp file. When I import tables from this file, I got hurt. I have used Enterprise Manager:
    1. connected by SYSTEM user as USUAL
    2 selected, choose the type of import - tables
    3. the data in the file imported
    4 selected tables to import tables
    5. in the next step, I try to insert a row into the table remapping patterns and change the cell Destination Shema, but in the list is only one name of shema - HR! Why?

    Published by: alvahtin on 10.03.2013 06:11

    ORA-39166: Object SYSTEM. EMPLOYEES were found.
    ORA-39166: Object SYSTEM. The DEPARTMENTS was not found.
    ORA-39166: Object SYSTEM. PLACES not found.

    Tables are not owned by system. Try

    impdp system/oracle remap_schema=hr:inventory tables=hr.employees, hr.departments, hr.locations ........
    
  • How to insert the data from the table file?

    I need to know that how can I insert data into multiple columns by file. I can simply insert data into a table of columns, but could not find a way to put the data in the column all.

    My data in a file store
    ************************************************text.txt***************
    133, nanny, nagina, 14 mph, 45637, 9156729863

    **************************************************************my_data(table)**********
    try to insert into table below...

    Name, ID, last_name, add, PIN. Mob

    *********************************************

    Let me know if you need anything else... :))

    Hey nanny.

    In fact, in SQL Developer, you can open a connection to the target schema, right-click on the Tables node in the Navigator tree, select import the data, then use the data import wizard. It is extremely flexible. Looks like you have a file of comma-separated variables, so if you select Format: csv and import method: Insert it will probably work fine.

    To minimize the risk of errors during import, choose a limit value of preview so that the wizard can review the data type and the size of all columns in several lines of data as possible, and then examine the size/type of data for each column on the next page of the wizard and replace if necessary. For date columns, it is also important to choose the appropriate format mask.

    Hope this helps,
    Gary
    SQL development team

  • Choose the date between December 1 and March 1

    I have a table in which I include the date column and the temperature.

    Now, I want to choose the average temperature per season per year. For the spring until autumn, it's perfectly feasible:

    But what about winter. Winter begins December 1st and ends March 1 of next year. Can someone help me?

    The result in plain language should be:

    Select the year (deducted from 1 December), avg (temp) of weatherdata if date between 01-dec-current_year and 01-March-next_year.

    year - avg (temp)
    2010 - 5 (from December 2010 1 until March 1, 2011)
    2011. 1 of dec 1, 2011 until March 1, 2012)
    2012-3 from December 2012 1 up to March 1, 2013) will be in the future.

    Published by: dkoetsier on August 31, 2012 05:15

    I never suggested to the group only by reference. I geve suggestion you how to calculate the name of season. Of course, you also need this season belongs to which is:

    TO_CHAR (ADD_MONTHS (Datum,-2), 'YYYY')

    Here are the two pieces of data that must be grouped together. In order to obtain the average temperature in season:

    select  case to_char(add_months(datum,-2),'Q')
              when '1' then 'Spring'
              when '2' then 'Summer'
              when '3' then 'Fall'
              else 'Winter'
            end || ' of ' || to_char(add_months(datum,-2),'YYYY') season,
            avg(temp)
      from  weerdata
      group by to_char(add_months(datum,-2),'YYYY'),
               to_char(add_months(datum,-2),'Q')
    /
    

    SY.

  • How to write a simple select query to get the data of the table as an XML.

    How to write a simple select query to get the data of the table as an XML. In the query, I'm just adding items below which i need be there in the XML document
    select '<test_tag>'||EMP_NAME||'</test_tag>','<date>'||sysdate||'</date>' 
    from temp_table where id_num BETWEEN 1 AND 10;
    I have need to add the root tag as well in the beginning and the end of < root > < / root > this xml file. Please advice if this is possible with the select query
    without using XMLGEN, XMLQUERY or any other packages built and function?

    I need to URL escapes with the UTF-8 code points that we have already achieved using the utl_http package. Please help how to do that without using the utl_http package.

    What is wrong with him?

    At present, the only way I can think of to avoid a call to UTL_HTTP. SET_BODY_CHARSET is to write your own little wrapper.
    In this way, you can specify the Boolean parameter or omit it if you choose to use named parameters:

    SQL> create or replace function my_url_escape (url in varchar2)
      2  return varchar2
      3  deterministic
      4  is
      5  begin
      6   return utl_url.escape(url, false, 'AL32UTF8');
      7  end;
      8  /
    
    Function created
    
    SQL> select my_url_escape('http://some.uri.com/param?lang=fr&text=contrôle') from dual;
    
    MY_URL_ESCAPE('HTTP://SOME.URI
    --------------------------------------------------------------------------------
    http://some.uri.com/param?lang=fr&text=contr%C3%B4le
     
    
  • Problem using applescript to put data into the table of numbers with column heads

    I have extracted the data from certain Web pages and want to place the data items in a table of numbers.  I wrote the applescript to extract pairs of data into two lists, but encountered a problem when you try to put the data items in a table of numbers.

    I hope I've isolated the problem eventually reduce version of the data table and writing.

    Calendar_Month

    Alvarez

    Laundry

    Linen

    Products

    March-2014

    April 2014

    May-2014

    Totals:

    0.00

    0.00

    0.00

    0.00

    Define theLabels to {"Alvarez", "Flax", "Laundry", "Products"}

    the nominative value {11, 22, 33, 44}

    Tell application "Numbers."

    say table 1 on sheet 1 of 1

    rowIndex Set of 3

    q Set of 2

    say the line rowIndex

    colHead theLabels point q value

    the columnIndex value address column colHead

    tell the cell (columnIndex)

    value defined in point q of the nominative case

    tell the end

    tell the end

    tell the end

    tell the end

    I arbitrarily chose to line 3 of the table to demonstrate the problem.

    Each data item is associated, due to its position in the list, with a label that determines the column of the data table, where it should be placed.

    The illustrated script pitches the 2nd data element in the list in the column headed "Lin".  This seems to work ok.  But if q is set to 1 the script fails with

    get address of column "Alvarez" in line 3 of table 1 to sheet 1 of the document 1

    -> error number - 1728 column "Alvarez" in line 3 of table 1 of sheet 1 of document 1

    It fails also with q the value 3 or 4.

    I probably did something really stupid, but I can't understand this behavior.  Advice please?

    Under: Numbers v.3.6.1 Script Editor 2.7 2.4 OS X 10.5.5 Applescript

    Two questions.

    (1) the order of the text in theLabels = {"Alvarez", "Flax", "Laundry", "Products"} and differ from the order of the text in the header row. Is this correct?

    (2) you are putting the value 22 (point 2 of nominative) in cell D3, where column heading of D = "Flax", which is article 2 of the theLabels?

    Respect,

    H

  • will choose the manually back option in iTunes backup everything that is on my iPhone to my computer? Including the app data

    Not a problem just a question. I intend to sell my apple iPhone, it's not compatible with my new wireless network. I can't afford to buy an iPhone outright at the moment, but I plan in the future. I want to backup everything on my iPhone to my Mac so that I can restore the data to a new iPhone later. The current iPhone 5 is already set to save important things to iCloud, if I choose the option with a manual backup encryption will be that record everything, including all the data from the app? Sorry if this is a stupid question, I want to just make sure I have everything before you send the iPhone.

    Hello CallRinny,

    I understand that you have a question about your iTunes backups and that you should use. Back on which covers.

    In general, an iTunes backup will cover pretty much everything on your iPhone. The best thing to watch over it, it's what doesn't iTunes back upwards and which covers the encrypted backup. Take a look at the information below to clarify this. I would also do that applications will be recorded in your iTunes library, so when you restore your backup, apps will sync back to the wire in one sitting instead to download on the App Store.

    On safeguards in iCloud and iTunes
    https://support.Apple.com/en-us/HT204136

    backup iTunes

    On your Mac or PC, you can make a backup of your device in iTunes. Synchronize your device with your computer is not the same as performing a backup.

    An iTunes backup includes almost all settings and data from your device. An iTunes backup does not include:

    • Content of the iTunes and App Store or directly downloaded from iBooks PDF files (you can save this content using transfer purchases in iTunes.)
    • Synchronized content from iTunes, as imported MP3s or CDs, videos, books and photos
    • Photos already stored in the cloud, like My Photo Stream and iCloud photo library
    • Tap Settings ID
    • Settings and information Apple pay
    • Data activity, health, and keychain (to save this content, you will need to use iTunes backup encrypted ).

    Learn How to perform backups in iTunes, how to find them on your Mac or PC, and how to delete backups you no longer need.

    Let me know if this clears it for you.

    Take care

Maybe you are looking for