Getting a list of dates between 2 dates

Hi All,
Is there a way I can generate a list of date using a simple SELECT statement to generate all dates between to date points? For example between SYSDATE AND SYSDATE-7?
One way I know is have a table and run PL/SQL script to put all dates in it and query that but was wondering if it can be achieve via SQL SELECT query at all without creating a table (querying DUAL).
Cheers.
Using Oracle XE 11GR2

Arc_x wrote:
If I wanted to make both days Inclusive how would I achieve that?Maybe: NOT TESTED!
select to_date(:start_date,'yyyymmdd') + level - 1 generated_date
  from dual
connect by level <= to_date(:end_date,'yyyymmdd') - to_date(:start_date,'yyyymmdd') + 1Regards
Etbin

Similar Messages

  • How to get a list of dates given a range

    Hi,
    I need to get the list of the dates from today. i.e, the list of last 30 days from today. What is the query to fetch the list of date values? I know to get the current date using sysdate function in oracle, but to fetch the list of 30 days from current date like20-07-2011,19-07-2011,18-07-2011,17-0702011......
    Please help me to get the list of dates..
    Regards,
    Pradeep
    Edited by: 873670 on Jul 20, 2011 4:03 AM

    One way to do it....
    SELECT
        SYSDATE - (ROWNUM - 1)
    FROM
        dual
    CONNECT BY
        level <= 30

  • How to get the list of data providers used in a web template?

    I want to find a quick way to retrieve the list of data providers defined in the <object> tag in the Web template. One awkward approach is to parse the entire HTML page for <object> then filter out "DATA_PROVIDER: xxx".
    But is there any method or function call to retrieve the list quickly?
    Thanks!

    Try the function below, pass the item name and get the Data provider for that particular item, you will have to do this for all the items in the template.
    function getDPName(item){
         prop = SAPBWGetItemProp(item);
         var tableHidden=true;
         if (prop != null){
           for(i=1;i<prop.length;i++){
             if (prop<i>[0] == "DATA_PROVIDER")
                   return prop<i>[1]
           }//end for
         }//end if
    }//end function
    Thanks.

  • SQL query to get a list of relations between workitems

    How can I create a SQL query to get a list of all problems with related changes?  And all problems with related incidents?
    I have tried to join the tables RelationshipTypeDim with ProblemDimKey and ChangeRequestDim, but the results are not correct.

    The relationships in the data warehouse can be kind of tricky. The relationships are contained in the WorkItemRelatesToWorkItemFactvw table. This table lists the related items by their WorkItemDimKey, so you cannot reference directly from the ChangeRequestDimvw
    or ProblemDimvw. You will need to reference the WorkItemDimvw to get the WorkItemDimKey for each entry.
    The query below will get all of the related work items from the Change Request class. The way the joins work is ChangeRequestDimvw gets the list of change requests. Then inner joins WorkItemDimvw to get the WorkItemDimKey for each CR. Then inner joins WorkItemRelatesToWorkItemFactvw
    to get all of the CRs with related work items. Then inner joins the WorkItemDimvw again to get the ID of the related work item. 
    Now the tricky part is it appears that these relationship are set based on which item  that created the relationship. So you need to union a second query that reverse the relationship on the WorkItemRelatesToWorkItemFactvw. 
    This query should give you a good start on getting the related work items. You can filter it down from here if you only want to include problems.
    SELECT C.ID, WIWI.ID
    FROM dbo.ChangeRequestDimvw C
    INNER JOIN dbo.WorkItemDimvw WI ON
    WI.EntityDimKey = C.EntityDimKey
    INNER JOIN dbo.WorkItemRelatesToWorkItemFactvw AS WIRWI ON
    WIRWI.WorkItemDimKey = WI.WorkItemDimKey
    INNER JOIN dbo.WorkItemDimvw AS WIWI ON
    WIWI.WorkItemDimKey = WIRWI.WorkItemRelatesToWorkItem_WorkItemDimKey
    union
    SELECT C.ID, WIWI.ID
    FROM dbo.ChangeRequestDimvw C
    INNER JOIN dbo.WorkItemDimvw WI ON
    WI.EntityDimKey = C.EntityDimKey
    INNER JOIN dbo.WorkItemRelatesToWorkItemFactvw AS WIRWI ON
    WIRWI.WorkItemRelatesToWorkItem_WorkItemDimKey = WI.WorkItemDimKey
    INNER JOIN dbo.WorkItemDimvw AS WIWI ON
    WIWI.WorkItemDimKey = WIRWI.WorkItemDimKey
    Order by C.ID
    Matthew Dowst |
    Blog | Twitter

  • List of dates for a week

    Hi,
    i´m looking for a way to get the list of dates for a specific week.
    i.e.
    Week 41.2007 returns
    08.10.2007
    09.10.2007
    10.10.2007
    14.10.2007
    Any suggestions how to do this?

    that all depends on your definition of a calendar.
    does the 1st week of the year start on Jan 01? or
    does it start on the sunday of the week (sun-sat)
    that contains Jan 01? or do you use a mon-sun
    calendar instead?I didn't think it depends on the definition of the calender since weeks run indepenant from the calender year. However we are talking about a calender week. There is an iso-definition for it, which is also implemented by Oracle.
    Week number
    Weeks in a Gregorian calendar year can be numbered for each year. This style of numbering is commonly used (for example, by businesses) in some European and Asian countries, but rare elsewhere.
    Straight from Wikipedia:http://en.wikipedia.org/wiki/Week#Weeks_and_the_calendar_year
    ISO 8601 includes the ISO week date system, a numbering system for weeks; each week is associated with the year in which Thursday occurs (so that if a year starts in a long weekend Friday–Sunday, week one of the year will start after that). Thus, for example, week 1 of 2004 (2004W01) ran from Monday 29 December 2003 to Sunday, 4 January 2004. The highest week number in a year may be 52 or 53.
    The numbering system in different countries may deviate from the international ISO standard. There are at least six possibilities[2] [3]...
    >
    so, as per the OPs question, my solution is perfect.No it was not. But mine was neither. OP gave the example for 2007 but never said it will always be this year. Just like OP gave example of 41 as the week.
    -snip-
    so the 7 days would then be:
    trunc( to_date('01-jan-'|| any_year, 'dd-mon-yyyy'),
    'D' ) + ( week_num-1 )*7This is much better than my version!

  • Last day from the list of dates

    i have a query which give me list of dates. From these list of date i want to find the last day in all months. when i am using last day fucntion i am getting last day from the sysdate and not from the list of dates generated by my query.
    the query
    (select distinct to_date(substr(batch_id,1,6),'DDMMRR') batch_id from gcon_mst_v0)
    order by batch_id desc
    i want last day from each month from the list of dates listed from the query.
    Help would be higly appriciated
    Thanks in advance

    The column is a varchar but i am convering it to get
    the list od dates as you can see in the query. i want
    all the last dates of every month from that list of
    dates for eg. below is the list of the dates i am
    getting from the query.
    7/11/2007
    7/10/2007
    7/9/2007
    7/8/2007
    7/6/2007
    7/5/2007
    7/4/2007
    7/3/2007
    7/2/2007
    7/1/2007
    6/29/2007
    6/28/2007
    6/27/2007
    6/26/2007
    6/25/2007
    6/24/2007
    6/22/2007
    6/21/2007
    6/20/2007
    6/19/2007
    6/18/2007
    6/17/2007
    6/15/2007
    6/14/2007
    6/13/2007
    6/12/2007
    6/11/2007
    6/10/2007
    6/8/2007
    6/7/2007
    6/6/2007
    6/5/2007
    6/4/2007
    6/3/2007
    6/1/2007
    5/31/2007
    5/30/2007
    5/29/2007
    5/28/2007
    5/27/2007
    5/25/2007
    5/24/2007
    5/23/2007
    5/22/2007
    5/21/2007
    5/20/2007
    5/18/2007
    5/17/2007
    5/16/2007
    5/15/2007
    5/14/2007
    5/13/2007
    5/11/2007
    5/10/2007
    5/9/2007
    5/8/2007
    5/7/2007
    5/6/2007
    5/4/2007
    5/3/2007
    5/2/2007
    5/1/2007
    4/30/2007
    4/29/2007
    4/27/2007
    4/26/2007
    4/25/2007
    4/24/2007
    4/23/2007
    4/22/2007
    4/20/2007
    4/19/2007
    4/18/2007
    4/17/2007
    4/16/2007
    4/15/2007
    4/14/2007
    4/12/2007
    4/11/2007
    4/10/2007
    4/9/2007
    4/8/2007
    4/6/2007
    4/5/2007
    4/4/2007
    4/3/2007
    4/2/2007
    4/1/2007
    3/30/2007
    3/29/2007
    3/28/2007
    3/27/2007
    3/26/2007
    i want the last date for all the months listed. that
    would be
    6/29/2007 -- last day for june
    5/31/2007-- last day for may
    4/30/2007-- last day for april
    3/30/2007-- last day for march and so on
    thankswrite query as
    SELECT LAST_DAY(TO_DATE(SUBSTR(COLUMN_NAME,X),'MM/DD/YYYY'))
    FROM TABLE_NAME

  • How to get a list of material numbers(IDH) generated between two dates

    Hi
    I want to get a list of mateial numbers which are uploaded in last one year.Need help.

    Look at classes Calendar and SimpleDateFormat.
    And get your abstraction straight: you don't have two dates. You have two Strings that represent a date. To use them, you have to convert them to Date objects first with SDF.

  • Need Help on List of Months between Two Dates

    Hello everyone,
    I have a table which has startdate & enddate, and need a SELECT statement to list all months between these two dates for each given ID.
    I did some test, and could not figure out how to get the startdate & enddate from testing table (instead of hard code them) in the select statement.
    Could anybody please help on it (Oracle 11gR2),
    Thanks in advance!!!
    create table testing(
    id          number,
    start_date  date,
    end_date    date);
    insert into testing values(100, to_date('05-FEB-2011', 'DD-MON-YYYY'), to_date('28-MAY-2011', 'DD-MON-YYYY'));
    insert into testing values(200, to_date('20-JUN-2011', 'DD-MON-YYYY'), to_date('28-DEC-2011', 'DD-MON-YYYY'));
    commit;
    select * from testing;
            ID START_DAT END_DATE
           100 05-FEB-11 28-MAY-11
           200 20-JUN-11 28-DEC-11
    Elapsed: 00:00:00.01
    *for testing.id = 100:*
    select to_char(add_months(to_date('05-FEB-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates
    from (select level l
           from dual
        connect by level <= months_between(trunc(to_date('28-MAY-2011', 'DD-MON-YYYY'), 'MONTH'),
                                           trunc(to_date('05-FEB-2011', 'DD-MON-YYYY'), 'MONTH')) + 1);
    DATES
    2011-Feb
    2011-Mar
    2011-Apr
    2011-May
    Elapsed: 00:00:00.01
    *for testing.id = 200:*
    select to_char(add_months(to_date('20-JUN-2011', 'DD-MON-YYYY'), l - 1), 'YYYY-Mon') Dates
    from (select level l
           from dual
        connect by level <= months_between(trunc(to_date('28-DEC-2011', 'DD-MON-YYYY'), 'MONTH'),
                                           trunc(to_date('20-JUN-2011', 'DD-MON-YYYY'), 'MONTH')) + 1);
    DATES
    2011-Jun
    2011-Jul
    2011-Aug
    2011-Sep
    2011-Oct
    2011-Nov
    2011-Dec
    7 rows selected.

    SQL> select * from testing
      2  /
            ID START_DAT END_DATE
           100 05-FEB-11 28-MAY-11
           200 20-JUN-11 28-DEC-11
    SQL> select  id,
      2          to_char(add_months(start_date,column_value - 1),'YYYY-Mon') dates
      3    from  testing,
      4          table(
      5                cast(
      6                     multiset(
      7                              select  level
      8                                from  dual
      9                                connect by add_months(trunc(start_date,'MM'),level - 1) <= end_date
    10                             )
    11                     as sys.OdciNumberList
    12                    )
    13               )
    14    order by id,
    15             column_value
    16  /
            ID DATES
           100 2011-Feb
           100 2011-Mar
           100 2011-Apr
           100 2011-May
           200 2011-Jun
           200 2011-Jul
           200 2011-Aug
           200 2011-Sep
           200 2011-Oct
           200 2011-Nov
           200 2011-Dec
    11 rows selected.
    SQL> SY.

  • Require the list of dates exist between dates

    in 10g database i can execute the below query
    Iam having a table sdate
    pk     startdate     enddate     des1
    1     1/1/2010     1/3/2010     xxxxxxxxc
    2     1/5/2010     1/20/2010     abc
    i need list of dates between startdate and enddate, so i created this query
    SELECT DISTINCT d, des1
    FROM (SELECT pk, s.startdate + LEVEL - 1 d, des1
    FROM sdate s
    CONNECT BY LEVEL <= (SELECT enddate - startdate + 1 FROM sdate y WHERE s.pk = y.pk))
    ORDER BY d, des1
    but in 9i database if i execute the same above query iam getting
    ORA-01473: cannot have subqueries in CONNECT BY clause
    **is there any other way to view list of dates for the given range of date**

    SQL>WITH sdate AS
      2       (
      3          SELECT 1 AS pk, DATE '2010-1-1' AS startdate, DATE '2010-1-3' AS enddate, 'xxxxxxxxxxxcxx' AS des1
      4            FROM DUAL
      5          UNION ALL
      6          SELECT 2 AS pk, DATE '2010-1-5', DATE '2010-1-20', 'abx' AS des1
      7            FROM DUAL)
      8  SELECT startdate + d - 1, des1
      9    FROM (SELECT     ROWNUM AS d
    10                FROM (SELECT MAX(enddate - startdate) + 1 AS maxrange
    11                        FROM sdate)
    12          CONNECT BY LEVEL <= maxrange),
    13         sdate
    14   WHERE d <= enddate - startdate + 1;
    STARTDAT DES1
    01.01.10 xxxxxxxxxxxcxx
    02.01.10 xxxxxxxxxxxcxx
    03.01.10 xxxxxxxxxxxcxx
    05.01.10 abx
    06.01.10 abx
    07.01.10 abx
    08.01.10 abx
    09.01.10 abx
    10.01.10 abx
    11.01.10 abx
    12.01.10 abx
    13.01.10 abx
    14.01.10 abx
    15.01.10 abx
    16.01.10 abx
    17.01.10 abx
    18.01.10 abx
    19.01.10 abx
    20.01.10 abx
    19 rows selected.
    Elapsed: 00:00:00.07Urs
    Edited by: metzguar on 09.07.2010 14:36

  • Looping through a refcursor to get list of dates as a string

    hi,
    i have a simple procedure which gives me list of from dates and to dates
    i need to get the dates a comma separated dates
    i am not sure if this can be done directly by doing a for loop on the refcursor or i have to fetch it into a record/array and then concatenate with comma or is there anything else that can be done.
    i tried out some stuff like below
    ps help me out
    the procedure that retruns the list of dates is
    CREATE OR REPLACE procedure SALUSER.prm_sp_rpt_payslip_lop_dates(p_empid in int,p_tran_year in int,p_tran_month in integer,o_dates out sys_refcursor)
    as
    begin
    open o_dates for select  to_char(PHL_LOP_FROM,'DD-Mon-YYYY'),to_char(PHL_LOP_TO,'DD-Mon-yyyy')
                     from prm_h_lop
                     where phl_emp_id=p_empid
                       and phl_tran_year=p_tran_year
                       and phl_Tran_month=p_tran_month;
    end;
    /i need my o/p as
    dates :<date1>,<date2>...etcregards,

    Maybe sth. like
    SQL>  var cur refcursor
    SQL>  declare
    cr sys_refcursor;
    procedure prm_sp_rpt_payslip_lop_dates (cr in out sys_refcursor)
    as
    begin
       open cr for select hiredate from emp;
    end prm_sp_rpt_payslip_lop_dates;
    begin
    prm_sp_rpt_payslip_lop_dates(cr);
    open :cur for select 'Dates: ' || column_value dates from xmltable('string-join(//text(), ", ")' passing xmltype(cr));
    end;
    PL/SQL procedure successfully completed.
    SQL>  print cur
    DATES                                                                          
    Dates: 17-Dec-1980, 20-Feb-1981, 22-Feb-1981, 02-Apr-1981, 28-Sep-1981, 01-May-1
    981, 09-Jun-1981, 19-Apr-1987, 17-Nov-1981, 08-Sep-1981, 23-May-1987, 03-Dec-198
    1, 03-Dec-1981, 23-Jan-1982                                                    
    1 row selected.

  • Camel Query : Calender list : Get Items agains given date that must be greater than and eqaul to start date and greater less than or equal to end date ?

    Camel Query : Calender list : Get Items agains given date that must be greater than and eqaul to start date and greater less than or equal to end date ?
    A Snap of Employee holiday list
    Case : Anne juul Sondergaar is on leave from 05-06-2014 to 07-06-2014
    I need a query to check wheither Anne juul is on leave at 06-06-2014 ????
    I am using this query that return nothing
    SPQueryquery =
    newSPQuery();
                                query.Query =
    @"<Where>
    <And>
    <And>
    <Leq>
    <FieldRef Name='Til' />
    <Value Type='DateTime'>"
    + WorkingStartDate.ToString("yyyy-MM-dd")
    + @"</Value>
    </Leq>
    <Geq>
    <FieldRef Name='Fra' />
    <Value Type='DateTime'>"
    + WorkingStartDate.ToString("yyyy-MM-dd")
    + @"</Value>
    </Geq>
    </And>
    <Eq>
    <FieldRef Name='Medarbejdere' />
    <Value Type='Lookup'>"
    + EmployeeName.Trim() +
    @"</Value>
    </Eq>
    </And>
    </Where>"
                                query.ViewFields =
    " <FieldRef Name='ID' />";
    Ahsan Ranjha

    Hello,
    Download CAML query builder from below location and use it to build your query:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/f7b36ebc-6142-404a-8b04-9c87de272871/where-can-i-download-the-u2u-caml-query-builder-for-sharepoint-2010may-i-know-the-exact-link?forum=sharepointgeneralprevious
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to get the list data in MM01/MM02 Classification view

    Hi,
    Anyone know the FM that we use for getting the list in Clasification View of MM01/MM02?
    Thanks,
    Alfred

    hii,
    U can use the below fm to get the classification view in MM02..
    CLFM_OBJECT_CLASSIFICATION
    CLFM_OBJECTS_CLASSIFICATION
    BAPI_OBJCL_CREATE_KEY
    CLFM_CLASS_CLASSIFICATION
    or if u want data from classificaton view then use this function module.
    CLAF_CLASSIFICATION_OF_OBJECTS
    Regards,
    Anil N.

  • Getting the list of  files in a directory by their last modified date

    Dear friends,
    I want to get the list of files in a directory sorted by their last modified date.
    By default the file.list() or listFiles() return files sorted by their name in ascending order.
    Please give me your suggestions.
    Thanks in advance,
    James.

    Thanks friend,
    I myself got the answer
    here is my code:
    public File[] getSortedFileList(File dir){
    File[] originalList = dir.listFiles();
    int numberOfFiles = originalList.length;
    File[] sortedList = new File[numberOfFiles];
    long[] lastModified = new long[numberOfFiles];
    for(int i = 0; i < numberOfFiles; i++){
    lastModified[i] = originalList.lastModified();
    Arrays.sort(lastModified);
    for(int i = 0; i < numberOfFiles; i++){
    for(int k = 0; k < numberOfFiles; k++){
    if(originalList[k].lastModified() == lastModified[i])
    sortedList[i] = originalList[k];
    System.out.println("The sorted file list is:" + sortedList[i]);
    return sortedList;

  • Any way to get a list of projects created before or after a certain date?

    Ladies and Gents,
    Now that libraries can be so easily switched between with Aperture, i'm trying to get a list of my projects that can be moved to an Aperture archive library. I can setup smart albums but that only matches actual photos, not entire libraries.
    My end goal is to simply select the oldest libraries in my current library, export and remove them from my current library, then import them into my archive library.
    Can anyone assist?
    Thanks,
    Ricardo Meleschi

    - Look into File->Relocate Masters and the subfolder dropdown for organizing your file structure.
    If you use referenced masters, you can more easily do what you're mentioning by export libraries out for each year, and have the masters in a folder setup to match.
    < Edited by Host >

  • Need help with Expressions to get the sum of rows between dates

     Date              Total
    8/06/2010     $2000
    8/10/2010    $5000
    8/28/2010      $2500
    9/10/2010    $5000
    9/16/2010   $2000
    9/25/2010   $7000
    9/28/2010     $2500
    I need sum of rows based on month. I have tried  following syntax. It did not work, which is returning $0.  Appreciate any help i get.
    =sum(iif(Date.value>="8/01/2010" AND Date.value<="8/30/2010",Total.value,0))

    Hi RG K,
    According to your description, you want to calculate sum of total based on month use expression, but the expression does not work. If that is the case, please refer to the following steps:
    In design surface, right-click Insert and click Text Box.
    Right-click inside of the text box, then click expression.
    In Expression text box, type the expression like below:
    =sum(iif(Fields!Date.Value>="8/01/2010" AND Fields!Date.Value<="8/30/2010",Fields!total.Value,CDec(0)))
    In this expression, the data type of total is Decimal, so we need to convert 0 to Decimal use CDec() function. If data type of total is Double, we need to use CDbl() function.
    The following screenshot is for your reference:
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

Maybe you are looking for

  • How do I hide a pulldown menu if one of it's values has been selected but not others?

    Through searching this forum, I've been able to figure out how to hide pull downs and fields that only have numeric info in them. I.e if the user selects. or if the pulldown value is zero. The item does not show or print on the form.  What I cannot f

  • Printer server for two HP printer on VISTA PC

    I have just purchased a Dell pc with the VISTA operation system. I have two HP printers: HP Laser Jet 4100, Model CAAC049A, Serial # USJNG10352 and a HP business inkjet 2250, Model C2691A#ABA, Serical # SSG095110PR. I want to set them up so all PC's

  • Fonts display : Please help

    Hai friends, We migrated forms6i to forms 10g. But when displying forms thru browser, Fonts are not comming properly. eg: Command button title is "Leave Allowance" It is comming like this, "Leave A....." Any one please help me. regards Mathew

  • Reader X Preview in Outlook x64 in W7 x64 SP1

    Windows 7 SP1 just rolled out on my auto update and it seemed about the same time I found Adobe Reader updating to X.  I use the PDF preview in Outlook quite a bit and noticed after these updates that is doesn't work again.  I had installed a "fix pa

  • Upload PDF file to Webdynpro

    Hi Experts, I have read lots of posts, but any post could help me. Perhaps this post may help more people. I have to upload a PDF file to show its contents either implace or in a new window. The FileUpload UI Elements is useless because it needs the