How to count the number of Sundays between the two dates

Hello

I want the number of Sundays between the two dates

example of

number of number of Sundays between 4 January 2013 ' and April 30, 2013 "in a select query, I have to include this as a sub query in my select statement.

nordine B wrote:
Hi Frank,.
Have 1 doubt...

In many countries the week could me "Monday". How the application handles it?
Or did I get something wrong?

Help, please!

For ' IW'(ISO week) early in the day is always Monday...

It's so simple - calculate the weeks between two dates based on Monday... This is the number of Sundays...

NEXT_DAY is another option...

SQL> with dd as
  2  (
  3      select TO_DATE('01-04-2013','dd-mm-yyyy') fdt, TO_DATE('30-04-2013','dd-mm-yyyy') ldt from dual
  4  )
  5  SELECT       fdt,ldt,
  6            (next_day(ldt,'sunday')-next_day(fdt-1,'sunday'))/7 sdays
  7  FROM         dd;

FDT       LDT            SDAYS
--------- --------- ----------
01-APR-13 30-APR-13          4

Published by: JAC on May 2, 2013 12:20

Tags: Database

Similar Questions

  • How to count the continuous dates in oracle 11g

    Hello

    I need to count the continuous more than 9 days between given dates below is my example

    Are my data like this
    MAY 1, 2013
    MAY 2, 2013
    MAY 3, 2013
    MAY 4, 2013
    MAY 5, 2013
    6 MAY 2013
    MAY 7, 2013
    MAY 8, 2013
    MAY 9, 2013
    MAY 10, 2013

    Now I want the number of days between these continuous days of more than 9 days now, I will get the result for the above data is 10 days
    If any date is not in the list then days would not result if it is less, then are equal to 9 days
    Here is an example of another
    MAY 1, 2013
    MAY 2, 2013
    MAY 3, 2013
    MAY 4, 2013
    MAY 5, 2013
    6 MAY 2013
    MAY 7, 2013
    MAY 8, 2013
    MAY 10, 2013
    11 MAY 2013

    number of days here is 10 but may 9, 2013 is away at the moment, the county should not show as 10 because continuous date (May 9, 2013) is absent, that's what I need, please suggest the solution.

    using the {: identifier of the thread = 1005478}

    SQL> ed
    Wrote file afiedt.buf
    
      1  with test as
      2  (
      3  select date '2013-5-1' dt from dual union all
      4  select date '2013-5-2' dt from dual union all
      5  select date '2013-5-3' dt from dual union all
      6  select date '2013-5-4' dt from dual union all
      7  select date '2013-5-5' dt from dual union all
      8  select date '2013-5-6' dt from dual union all
      9  select date '2013-5-7' dt from dual union all
     10  select date '2013-5-8' dt from dual union all
     11  select date '2013-5-9' dt from dual union all
     12  select date '2013-5-10' dt from dual union all
     13  select date '2013-5-11' dt from dual union all
     14  select date '2013-5-13' dt from dual union all
     15  select date '2013-5-14' dt from dual union all
     16  select date '2013-5-15' dt from dual union all
     17  select date '2013-5-16' dt from dual union all
     18  select date '2013-5-17' dt from dual
     19  )
     20  select min(dt),max(dt),count(*)
     21  from (select dt,
     22        dt-Row_Number() over(order by dt)
     23        as disTance
     24        from test)
     25  group by disTance
     26* order by min(dt)
    SQL> /
    
    MIN(DT)   MAX(DT)     COUNT(*)
    --------- --------- ----------
    01-MAY-13 11-MAY-13         11
    13-MAY-13 17-MAY-13          5
    
  • How to count the two archives as if only, day after

    Dear Sir

    I have a requirement to be employed data wise County but system consider a single record in the case of the following in the wake of the previous record.

    Helps explain, under the table, there are three employee records, but two recent reports is in line with December 25, 2013 to January 20, 2013. However, the first record of the 1 March 2013 to March 20, 2013.

    Now, I want to develop the query who consider the last two records only a first would be definitively unique. Result of the total count should be 2 according to my needs.

    --------------Table Data--------------------------

    EMP DATE_START, DATE_END

    1 1 MARCH 2013 MARCH 20, 2013

    1 DECEMBER 25, 2012 31 DECEMBER 2013

    1 1 JANUARY 2012 JANUARY 20, 2014

    Thank you.

    with

    table_data as

    (select 1 EMP, DATE_START, DATE_END of any double union to_date('20-MAR-2013','dd-MON-yyyy') to_date('01-MAR-2013','dd-MON-yyyy')

    Select 1,to_date('25-DEC-2013','dd-MON-yyyy'),to_date('31-DEC-2013','dd-MON-yyyy') in all the double union

    Select 1,to_date('01-JAN-2014','dd-MON-yyyy'),to_date('20-JAN-2014','dd-MON-yyyy') of double

    )

    Select emp, count (*) NTC

    from (select emp,

    date_start - lag (date_end) on date_diff (partition by order emp by date_start)

    of table_data

    )

    where date_diff > 1

    or date_diff is null

    Group by emp

    EMP CNT
    1 2

    Concerning

    Etbin

    Post edited by: Etbin

    command abducted by 1,2 - used as control of overlap

  • How to count the number of pages on the spread

    How to count the number of pages on the spread

    #include "ILayoutControlData.h".

    #include "ILayoutUIUtils.h".

    #include "ISpread.h".

    InterfacePtr layoutData (Utils()-> QueryFrontLayoutData());

    If (layoutData)

    {

    UIDRef spreadRef is layoutData-> GetSpreadRef();.

    InterfacePtr activeSpread (spreadRef, UseDefaultIID ());

    Int32 count is activeSpread-> GetNumPages();.   Number of pages of active propagation.

    }

  • How to count the number or lines in the file

    Hi Experts,

    I'm file as source and Oracle as target. My folder that contains some data that will load the target.
    My requirement is that I want to count the number of lines that contains my folder. Please help me how to count the total number of lines in the file.


    THX,
    Sara.

    Hi Sahaveda,

    Now, I tried and it works.

    Sorry my mistake again.

    I created HR. ETL_FILE_LOG as below:

    CREATE THE TABLE HR. ETL_FILE_LOG (numero_fichier varchar2 (10))

    Below the code will run without error:

    import java.lang as lang

    import java.sql SQL

    import of java.lang.String

    Import os

    disadvantages is sql. DriverManager.getConnection ("<%=snpRef.getInfo("DEST_JAVA_URL")%>", "<%=snpRef.getInfo("DEST_USER_NAME")%>", "<%=snpRef.getInfo("DEST_PASS")%>")

    dblinks = cons.createStatement)

    File1 = Open ('c:\EMP.txt','r')

    Count = 0

    Line = file1. ReadLine()

    all online! ='' :

    Count += 1

    Line = file1. ReadLine()

    File1. Close()

    sqlQuery = "insert into HR. "The values of ETL_FILE_LOG (numero_fichier) (" + str (count) + ' ") '.

    rqQuery = dblinks.execute (sqlQuery)

    jerks. Close()

    Concerning

  • How to count the number of hit on the page, click

    Hello..
    can someone tell me...
    How to count the number of hit on the page, click

    Thanks in anticipation...

    Somethig like that?
    http://www.baigzeeshan.com/2011/12/Oracle-ADF-storing-temporary-values-in.html

  • How to count the number of nodes under each parent in any given xml

    How to count the number of nodes under each parent in any given xml. for example the xml below was
    books has 3 childern, library [1] has 4, [2] library has 6 and bookshop [3] has 2. is it possible to get the number of tags in a childnode duplicate IE library [1]
    Book1 Tagus repeated twice... vice versa. do we need to make plsql lie we can achieve through sql

    < book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    ACR < book3 > < / book3 >
    ACR < book3 > < / book3 >
    tray of < bookn_1 > < / bookn_1 >
    adjusted cost base < bookn > < / bookn >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    < / books >


    I tried this... query.

    Select
    XMLQUERY ('count($doc/Books/Bookstore[1]/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    Select
    XMLQUERY ('count($doc/Books/descendant::*)' in the way of xmltype ("< books >
    < library >
    ABC < book1 > < / book1 >
    ACR < book1 > < / book1 >
    Lac < Book4 > < / Book4 >
    < / book >
    < library >
    ABC < book1 > < / book1 >
    BCA < book2 > < / book2 >
    < / book >
    (< / books > ')
    as 'doc' of happy return) .getNumberVal () as node_count
    of the double

    How can I get the counts for each parent in a single query

    Published by: user7955917 on August 24, 2012 07:26

    Generic function how you want the query to be.

    If the structure is known in advance, as in your example a 'books' and then a 'library' root element, it's as simple as:

    SQL> select x1.parent_id, x2.child_name, count(*)
      2  from tmp_xml t
      3     , xmltable(
      4         '/books/bookstore'
      5         passing t.object_value
      6         columns parent_id   for ordinality
      7               , child_list  xmltype path '*'
      8       ) x1
      9     , xmltable(
     10         '/*'
     11         passing x1.child_list
     12         columns child_name varchar2(30) path 'name()'
     13       ) x2
     14  group by x1.parent_id, x2.child_name
     15  order by x1.parent_id, x2.child_name
     16  ;
    
     PARENT_ID CHILD_NAME                       COUNT(*)
    ---------- ------------------------------ ----------
             1 book1                                   2
             1 book2                                   1
             1 book4                                   1
             2 bookn                                   1
             2 bookn_1                                 1
             2 book1                                   1
             2 book2                                   1
             2 book3                                   2
             3 book1                                   1
             3 book2                                   1
    
    10 rows selected
     
    

    If you want a generic solution that works without knowledge of the structure, you will need a recursive approach, and most importantly, you should know which nodes in distinct, I suppose that the leafs?

    Also, please help if you can provide the link of reference on the function name() years what are the other expression, that I can use after the path

    You can start reading the documentation: http://docs.oracle.com/cd/E11882_01/appdev.112/e23094/xdb_xquery.htm#CBAGCBGJ

    The clause PATH expects a XQuery expression however before 11.2, we can put only simple XPath expressions.

  • How to count the number of elements in a data block

    Hi all
    How to count the number of elements in a particular data block oracle Forms 10g.
    If it's a text_item or the display_item or the list_item etc is there any method to do this.

    Please answer...

    get the first element with GET_BLCOK_PROPERTY(..., FIRST_ITEM);
    loop until GET_ITEM_PROPERTY(..., NEXTITEM) is null
    count on in the loop.

  • How to count the number of columns in an oracle table using sql

    How to count the number of columns in an oracle table using sql

    You must put the name of the table in capital letters

    As

    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = 'EMP';
    
    or
    
    SELECT COUNT(1)
      FROM user_tab_columns
    WHERE table_name = UPPER('Emp');
    

    Concerning
    Arun

  • How to count the number of data records?

    Hey guys, how to count the number of records, I had on a data object variable?

    Im having a result of sql query in a variable like this:

    oDB.resolveNode("#command").query.select.value = "SELECT * FROM Customers WHERE CliNombre LIKE ' % ' + input1 +" %' ";

    oDB.open ();

    oDB.first ();

    So I need to count the number of records retrieved by this SQL query at the moment. Help please

    Then move the cursor back to the first record after you have your account.

    There is a keyword count in SQL that will allow you to get the account of your request. You can run that first - get your account, and then run the actual query to get the Recordset. This would require a separate data connection. Some examples of code.

    var xfa.event.newText = inName;
    If (inName == "") {}
    App.Alert ("you must enter a name--try again!")
    }
    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection2")
    {
    nIndex ++;
    }

    oDB = xfa.sourceSet.nodes.item (nIndex) .racing var (1); pertaining to the specified data connection node
    App.Alert (ODB.saveXML ("Pretty"));

    var nIndex = 0;
    While (xfa.sourceSet.nodes.item (nIndex) .name! = "DataConnection3")
    {
    nIndex ++;
    }
    var oDBCount = xfa.sourceSet.nodes.item (nIndex) .racing (1); pertaining to the specified data connection node
    Configure sql call DB to get the number of records that match the criteria

    oDBCount.nodes.item (1).query.setAttribute ("text", "commandType");
    oDBCount.nodes.item (1).query.select.nodes.item (0) .value = "Select count (*) from table1 where AcctNumber = '" + inName + "'";
    oDBCount.open)
    oDBCount.close)

    Configure sql call DB to get the specified employee number

    oDB.nodes.item (1).query.setAttribute ("text", "commandType");
    oDB.nodes.item (1).query.select.nodes.item (0) .value = "Select * from table1 where AcctNumber = '" + inName + "'";
    App.Alert (ODB. Nodes.Item (1) .saveXML ("Pretty"));

    now connect to the DB and get a recording
    oDB.open)
    oDB.close ();

    Note the SQL command use the keyword count (take a look at the oDBCount section). This will return a number of return to the cllaer. When I set up the data connection, a node count (*) that appeared there. I dragged to the form and it has created a field called count that the onus at this node. When the query is executed, the number of resulting records returns to this field. You can have hidden it so that your users can not see it and also to change the binding votes to zero, so it is not included in the data file that is submitted when the form is complete.

    Paul

  • How to count the page that is provided on page element

    How to count the page that is provided on page element

    Hi durgeshj41842015,

    the kDocBoss has an IPageList interface with GetPageCount() function.

    Markus

  • How to use the two counters to PXI-6280, to read and write at the same time?

    Hi all

    I try to use PXI-6280 counter to generate a command of step motor pulse train.  The idea is to send a number done and known pulse for the engine, which belongs to a system XYZ. The point is, if, at some point, the user or the security system can interrupt the movement. If this happens (and will be... a lot), I will lose the real position, because I don't know how many pulses were actually sent to the engine. That is why I want to use the other cost to count impulses how were actually sent to the engine. I can start any tasks (generating or account), but only the first started task will operate. I met a couple of mistakes and I'm not able to find a solution.

    Is it really possible to use the two counters? I've already done this in a pci system and worked without problems.

    Thanks in advance,

    Giavonna

    Electrical engineer

    I'm afraid that I don't understand your idea. Could explain you better?

    Material of the series M support pointing to an arbitrary digital signals at rates (the clock must be provided from another source, for example a counter).  If you want a digital pulse train finished output and have access to a counter (the two counters if find you another source for your clock, for example the subsystem "output frequency"), you must use this subsystem 'digital output' rather than the output of the counter.  There should be examples in the finder of the example shows how to configure a finished task of digital output.

    Now I'm generating sample clock having a single Timed material Point (the only mode accepts this mode), and configure the counter with finite samples.

    I don't think not just single point NI the hardware, that's what you want.  More commonly, output meter tasks use timing 'Implied', where the release date is implicitly determined by the characteristics of the pulse user-defined.

    Is there a way to stop the production of only one meter when a finite number of pulses has been played in another counter?

    Yes, but it's a little tricky.  You can set a trigger 'Pause' on the output task, with the soruce the break being the internal release of the counter used for the task of entry.  Set the initial value of the counter of entry to 2 ^ 32-N (or maybe 2 ^ 32-1-N, I don't have a system right now to check) where N is the desired number of pulse output.  Together the counter event behavior for the counter edges of County switch output (this is a property of DAQmx export Signal).  When the counter of entry reaches terminal, its in-house production switches, causing thus the task of output to pause.  You can then stop the task in the software (you should be able to use the output of the task of entry counter event to signal to the software when the output is paused).

    Now that I've written that the whole paragraph, I remember something * similar * to work around a limitation of the driver here .  It is not quite the same implementation I described above, but really, you can use a meter output or a counter entry to get the same effect (it could be a good place to start anyway if you want to try this).

    Is there a way to read pulses them how have been generated, without the other counter, counting impulses?

    N °

    Best regards

  • How to tie the two serial numbers using test including the tie in the database.

    I have two separate committees, I need to link the serial number too.  One is being tested as a separate unit, then the two are tested together, I need to make sure that I connect them in the database.  Don't know how to do it, looking for any input I can get.  Using a labVIEW vi to request the entry of a Board, and then use information interface to USE testbed for UUT of the hand.

    I have juries, one of the boards, A onboard, was tested by a different sequence file, then A is connected to Board B, and then they are tested as a complete set.  Received a few suggestions on how to save the two serial numbers, but went with a popup message added types of step (modified record results), and then just have the user scann the second number in and it stands as one of the results of the step in the database.

  • How to check the manufacturing date of the Z3 Compact?

    How to check the manufacturing date of the Z3 Compact?

    @HerrOdin

    Simple, pull on the flap of the IMEI and search for 14W__

    The first 2 digits are for the year and the last 2 digits are the week

    http://support.sonymobile.com/global-en/xperiaz3compact/Userguide/IMEI-number/

  • I try to combine a picture of my sister with a picture of a poem next to her. How to combine the two into a single photo?

    Paint or Windows Photo Gallery

    I try to combine a picture of my sister with a picture of a poem beside it, how to combine the two into a single photo?

    If you have the poem recorded in an image format,
    the following freeware can create a side by side
    Panorama.

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Download IrfanView
    http://MajorGeeks.com/IrfanView_d4253.html
    (filename: iview433_setup.exe)
    (uncheck if you don't want Google Chrome)

    Download plug-ins too...

    IrfanView plugins
    http://MajorGeeks.com/IrfanView_PlugIns_d4908.html
    (filename: irfanview_plugins_433_setup.exe)

    When the program is installed... read more...

    Open IrfanView and go... Image / create the Image of the Panorama...
    (this will open the screen to "Create a panorama image")

    On the screen to "Create a panorama image"... left click on the add images"" button.
    (Displays the 'Open' screen. Now, drill down to the
    the folder that contains your saved Photos of veterinarians.

    Now... click left (highlighted), the two images, you want to join.
    (you can select more than one if you hold down your Ctrl key)
     
    The two images highlight... left click on the button 'open '.
    (Or... you can add the images one at a time... which is always easier)

    Now, go back to the screen "Create the panorama image.
    and the file names of the selected pictures need to be in the
    Field "Input Images.

    Now with the names of two files in 'Images of entry' field...
    You can left click on the button 'create Image '.

    (the positions left and right of these images can be swapped in)
    selection of a file name and using the "mount image" / "Move."
    Images down"buttons...)

    Now you should see a display of the combined image.
    Reach... File / save as...

    Choose a backup location / enter a file name / choose a format...
    On the left, click on the button "Save..."

Maybe you are looking for