Problems computing dates within a given range based on conditions

Hello. I'm working on a part of a scheduling app and am having a problem with this one section. I tried doing some searches on this forum, but no one seems to be trying to compute anything similar to what I'm doing.
Basically, I have a select list with the values: "Every", "Every Other", "Every 1st", "Every 2nd", "Every 3rd", and "Every 4th". I also have a checkbox with the values for the days of the week, from Sunday to Saturday. What I'm trying to do is that if I have a start and an end date, how to compute which days (from the various combinations of the select list and checkbox items chosen) fall in this range. Are there any functions available to help with this task? Someone mentioned the next_day() function, but looking at that function it seems like this is still pretty complicated logic-wise. Is it, or am I missing something?

Hi,
As Etbin said, if you can get dbms_scheduler (or some other supplied code) to do all or part of your job, that's the best thing to do.
Assuming you have to produce a list of targeted run dates, here's a SQL query that does that.
The query uses four bind variables:
(1) :start_dt, a date in DD-Mon-YYY format (other formats would work as well; easily modified)
(2) :end_dt
(3) :freq_txt, one of 'Every', 'Every Other', 'Every 1st', etc.
(4) :day_txt, a comma-delimited list of days wanted, e.g. 'Tue,Thu'. (They don't have to be in order. If you're using 3-letter English abbreviations, they don't really have to be delimited.)
I assume your app can produce these from the screen inputs.
WITH     d     AS
(     -- Begin sub-query d to find all dates in range
     SELECT     TO_DATE (:start_dt, 'DD-Mon-YYYY') + LEVEL - 1     AS dt
     FROM     dual
     CONNECT BY     LEVEL <= TO_DATE (:end_dt, 'DD-Mon-YYYY')
                    + 1
                    - TO_DATE (:start_dt, 'DD-Mon-YYYY')
)     -- End sub-query d to find all dates in range
,     w     AS
(     -- Being sub-query w to compute week_num
     SELECT     dt
     ,     1 + FLOOR ((dt - TRUNC (dt, 'MM')) / 7)     AS week_num
     FROM     d
     WHERE     :day_txt     LIKE '%' || TO_CHAR (dt, 'Dy') || '%'
)     -- End sub-query w to compute week_num
SELECT     TO_CHAR (dt, 'DD-Mon-YYYY Dy')     AS run_dt
,     week_num
FROM     w
WHERE     (:freq_txt = 'Every')
OR     (:freq_txt = 'Every Other'     AND     week_num IN (1, 3, 5))
OR     (:freq_txt = 'Every 1st'     AND     week_num = 1)
OR     (:freq_txt = 'Every 2nd'     AND     week_num = 2)
OR     (:freq_txt = 'Every 3rd'     AND     week_num = 3)
OR     (:freq_txt = 'Every 4th'     AND     week_num = 4)
ORDER BY     dt
;If you don't understand what the subqueries are doing, run them alone. (e.g. "WITH d AS (...) SELECT * FROM d;")

Similar Messages

  • How to capture the data within the given range of maximum and minimum values ? from csv files

    My requirement,
    1. Here, the user will provide the range like maximum and minimum values, based on this range, the VI should capture the data within the given range. ( from CSV file as attached )
    2. Then VI should calcluate the average value for captured data and export it to excel.
    This is my requirement can anyone help me on this.
    Many thanks in advance
    rc_cks
    Attachments:
    sample_short.csv ‏2439 KB

    Hi,
    Thanks for remnding me. I forgt to attach the VI, 
    Here I am attaching the VI, what I tried. 
    From attached CSV file, I have to find an average value for columns B,C,D,E,F,G,H,I and AJ, AK. ( data range will be defined  by user ), focused only on these columns
    Here, the scope is to calculate an average value for given data range by user as MAX and MIN data.  
    FYI:  I tried manually for two instance i.e column H & I.  As per H column one steady state values from  7500 to 10500 and similarly in I column 7875 to 10050. So, I gave these as a limit to capture and calculate the average value. But unfortunaltely, requirement has been modified as per below requirements.
    More Info on requirement: 
    --> The user will define the range of data by giving some MAXIMUM and MINIMUM values(for above mentioned columns induvidually), then VI should capture          that data range and it has to caculate the average value for that range of data. This is the task I have to complete. 
    --> I am stuck in creating a logic for data capturing for given range of MAX and MIN value from user, 
         Can anyone help me on this. 
    If my explanation is not clear, Please let me know.  
    Many thanks, help mw
    rc
    Attachments:
    VI_rc.vi ‏25 KB
    sample.zip ‏4166 KB

  • Query for Old Data that does not match New Data within a given time period

    Hello all,
    One of the reports I need to create is for all associates who went from one department to another within a given time period. The way I ran this report in Reportsmith (pulling from our old system) was to compare the dept field from the beginning date to the dept field at the end date and it would give me those associate's that had moved. I had to do it this way b/c dept changes can happen using several different types of actions (supv change, promotion, etc.), none of them exclusive to just dept changes. We are now using Oracle HRMS and I need to create this same report with this system using SQL.
    Does anyone know how to compare data between two different dates and pull the ones that don't match? Your help will be GREATLY appreciated!
    Warm Regards,
    Yasmin E. Alberto
    HRIS Analyst
    [email protected]

    Hi, Yasmin,
    In the sample data you posted, nobody changed departments between May 1 and May 11. In fact, there were no assignments of any kind between January 16 and May 17, so I wouldn't expect any output for that period.
    A person (or rather, a duck) did change deptartments on May 20, so if you change the upper limit of the date range to
    AND    ASG_LAST_UPDATE_DATE < TO_DATE ('05/21/09', 'MM/DD/RR')you should see her.
    You've probably noticed that this site likes to compress white-space.
    To post formatted text (such as table results or indented code) type these 6 characters:
    (small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Selecting Missing Days from a given range of Date  from a table

    Dear Oracle Guru's
    Consider the following table
    txndetails
    Rundate date
    Txncnt Number
    userid varchar2(100)
    Data will be as follows
    Rundate txncnt userid
    17-Nov-2009 4 admin
    18-Nov-2009 7 admin
    21-Nov-2009 3 admin
    23-Nov-2009 4 admin
    We populate this table on the basis of txn generated. This is supposed to run daily based on the transactions. Certain days there wont be any transaction at all. hence there will be no entry on this table .
    At any given point of time , we would like to know the days on which there is no entries in this table
    In the above sample data, there is no entries on 19th, 20th and 22nd
    we have to list out those days
    I got confused while trying some methods
    Kindly guide me in this regard
    with warm regards
    Ssr

    Hi,
    As Centinul and Bhushan said, you need a list of all the possible dates; "CONNECT BY LEVEL <= x" is an efficient way to generate such a list in Oracle SQL.
    Once you have the list of all days, you can use MINUS, like Centinul or Bhushan did. You can also use an outer join, as shown below.
    WITH  extrema     AS
         SELECT     TRUNC (MIN (rundate))     AS start_date
         ,     TRUNC (MAX (rundate))     AS end_date
         FROM     txndetails
    all_days     AS
         SELECT     start_date + LEVEL - 1     AS a_date
         ,     start_date + LEVEL        AS next_date
         FROM     extrema
         CONNECT BY     LEVEL <= 1 + end_date - start_date
    SELECT     a.a_date
    FROM          all_days     a
    LEFT OUTER JOIN     txndetails     t     ON     t.rundate >= a.a_date
                                     AND     t.rundate <  a.next_date
    WHERE   t.rundate     IS NULL
    ;Remember that all DATEs include hours, minutes and seconds. In the list of all days that you generate, the hours, minutes and seconds will probably be 00:00:00; be careful if the hours, minutes and seconds in your actual DATEs are not always 00:00:00.
    The query above shows missing dates between the first date that is actually in the table and the last date in the table.
    In practice, most people are interested in a deffierent range, such as all dates between two given parameters, or all dates within the last year.
    If that's the case, you don't need the sub-query extrema; you can use the paremters (or compute the values) in all_days, based on dual.
    For example, to get the most recent 365 days:
    WITH     all_days     AS
         SELECT     TRUNC (SYSDATE) + LEVEL - 365     AS a_date
         ,     TRUNC (SYSDATE) + LEVEL - 364       AS next_date
         FROM     dual
         CONNECT BY     LEVEL <= 365
    SELECT     a.a_date
    ...          -- Same as beforeEdited by: Frank Kulash on Nov 23, 2009 10:54 AM

  • All the data that is equal within a certain range to be defined as equal in array

    Hi, I need to get some help!
    In edge detection, I get the result of all edges found in an array. When two or more edges is found close to eachother, I need to get them defined as one edge found.
    As an example, if the VI locate 10 edges, but 5 of them is close to eachother within a certain range, there will be only 6 result on the output.
    I'm quite new to Labview and will appreciate any sort of help

    I think I need help to solve the problem from scratch. As you can see in the picture it has been detected several edges in the middle of the picture. To the right in the picture you can see the array showing the Y-position of each edge detected. I need all edges that is within 30 pixels to eachother to be considered as one edge, and then compute the new array showing the position of the edges. 
    Attachments:
    example.JPG ‏95 KB

  • Obtaining data within a date range in XL Reporter

    Dear All,
    I'm currently working on BS in XL reporter.
    I was trying to extracting data in a date range, setting PER( Code >= @MthFrom Or Code <= @MthTo ) in report default tab.
    However, the result is shown as all data as of current date. E.g. Selection criteria: >=200808, <=200809, the result is shown as from Begining to 200810.
    Please kindly advise.
    Thank you.
    Regards,
    Julie
    Edited by: Julie Wan on Oct 1, 2008 1:10 PM

    Dear Gordon,
    Thank you for your reply.
    However my case is different to your given link.
    In my case, there is a result coming out, but not within the correct range i selected. It shows all instead.
    I tried to set the period range in report default tab,  in column tab of a expanding column, and in cell tab of an individual cell, but none have worked. E.g. PER( Code >= @MthFrom or Code <= @MthTo )
    Regards,
    Julie

  • Problem in data carrier "IDENTIFY FRONT END COMPUTER"

    hello all
    i am facing problem in data carrier creation for front end computer. actually i am creating data carrier type PC and i want set as default for all desktop. After  DEFINE DATA CARRIER TYPE SERVER, FRONT END and Select PC and IDENTIFY FRONT END COMPUTER its shows following error
    No entries found that match selection criteria
    Message no. SV004
    Diagnosis
    No entries were found when importing data from the data base.
    Procedure
    If you have specified selection conditions, start the transaction again with conditions that are less restricted.
    You can make new entries independently of this. To do this, select the function New entries in menu Edit.
    help me

    Hi Vivek,
    In the SAP standard this entry are maintained only by the system
    itself and they cannot be entered manually in transaction DC20. I can
    only provide you the following information on the possible settings for
    variable HOSTNAME and the DEFAULT frontend entry.
    1. Default entry
       Call transaction 'DC20'. Double-click node 'Define data carrier type
       "server, front end"'. Select the respective data carrier type (e.g.
       'PC') and double-click node 'Identify frontend computers'. Click
       button 'Default entry' in the top right corner of the table control.
       Note that it is only possible to create 1 default entry!
    2. System variable HOSTNAME
       If you run Windows XP, please go to Start -> Settings -> Control
       Panel. Double-click on 'System'. Click on tab 'Advanced' and then on
       button 'Environment variables'. Create system variable 'hostname' and
       assign a value'. Save the new variable.
    As there is already a DEFAULT entry for frontendtype 'PC' it cannot be
    maintained for another frontend type.
    Best regards,
    Christoph

  • Function Module to Compare Date within date Range

    Hi All,
            Does anyone know Function Module to Compare Date within date Range...For example i need to find whether 08/02/2006 falls in between 07/15/2006 and 09/15/2006......

    data: datum type sy-datum value '20070802',
          datum_low type sy-datum  value '20070730',
          datum_high type sy-datum value '20070930'.
    If datum between datum_low and datum_high.
    Endif.
    Regards,
    Rich Heilman

  • Where is the data stored for Formscentral subscribers based within the European Economic Area?

    We are already experimenting with Formscentral for some basic survey collection tasks, but I am interested in the potential to collect larger and more complex data sets.  However, being based within the European Economic Area it would be easier if the data collected from any of our online published forms remained within the EEA rather than being stored in the US.
    Does Adobe store EEA customers' data within the EEA or is it all stored within the US?

    Everything is stored within the US.
    Randy

  • Getting last-day-of-week dates within certain date range

    Hi all,
    I have the following Challenge:
    I want to know the dates of the last day of all the weeks within a certain range of dates.
    For instance if my range would be 01-jun-2002 - 31-jun-2002
    then the returned days should be (lastday of the week is sunday):
    . 02-jun-2002
    . 09-jun-2002
    . 16-jun-2002
    . 23-jun-2002
    . 30-jun-2002
    I want to accomplish this by only using sql (no pl/sql) in a ora 8.0.x rdbms
    How would I do this? (if it's possible)
    Tia,
    Martin

    Christian's solution returns
    01-JUN-02
    08-JUN-02
    15-JUN-02
    22-JUN-02
    on my system. The first day of the week is dependent on NLS settings.
    SELECT MAX(realdate)
    FROM (
    SELECT TO_CHAR(TO_DATE('31-may-2002','dd-mon-yyyy') + ROWNUM,'IW') weekno,
           TO_DATE('31-may-2002','dd-mon-yyyy') + ROWNUM realdate
    FROM all_objects
    WHERE rownum <= TO_DATE('30-Jun-2002','dd-mon-yyyy') - TO_DATE('01-Jun-2002','dd-mon-yyyy')
    GROUP BY weeknoThe IW format model give ISO standard week numbers and a week always starts on Monday.

  • TS2972 when i ask for Authorizeed computer i got the message " make sure your computer' date is set correctly and that it accepts cookies from the itunes stores " how can i solve this problem please .

    when i ask for Authorizeed computer i got the message " make sure your computer' date is set correctly and that it accepts cookies from the itunes stores " how can i solve this problem please .

    Ok, so I just worked out that itunes communicates through your browser so it's a cookie in the browser not PC direct that fixes this.  Bit of a convoluted route but for me it was IE>Internet setting>privacy>sites, then allow all activity from apple.com/itunes.

  • Populate dates within the date range columns in a table

    Hi ,
    I have a Students table with StudentID, StartDate and EndDate. For one of the requirements, I need to populate all the dates within and includeing the StartDate and EndDate for all the students. Please find the DDL for the source table samples and also below
    samples of Source table columns and how the output should be.
    create table #Students (ID int,startdate date,Enddate date)
    insert into #Students values (1000, '2014-01-01',
    '2014-01-10')
    insert into #Students values (1000, '2014-02-22',
    '2014-02-28')
    insert into #Students values (1001, '2013-07-01',
    '2013-07-12')
    insert into #Students values (1001, '2013-08-01',
    '2013-08-03')
    insert into #Students values (1001, '2014-04-01',
    '2014-04-05')
    --select * from #Students order by id,startdate
    --drop table #students
    Thanks in advance  for your help!

    Hi vskindia,
    A recursive way to achieve the expected output.
    create table #Students (ID int,startdate date,Enddate date)
    insert into #Students values (1000, '2014-01-01',
    '2014-01-10')
    insert into #Students values (1000, '2014-02-22',
    '2014-02-28')
    insert into #Students values (1001, '2013-07-01',
    '2013-07-12')
    insert into #Students values (1001, '2013-08-01',
    '2013-08-03')
    insert into #Students values (1001, '2014-04-01',
    '2014-04-05')
    ;WITH cte AS
    SELECT ID,startdate,Enddate FROM #Students
    UNION ALL
    SELECT ID,DATEADD(DAY,1,startdate) AS startdate,Enddate FROM cte
    WHERE startdate<Enddate
    SELECT id,startdate FROM CTE ORDER BY ID,startdate
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • Show current month's calendar based on computer date

    As a page loads, is it possible to check the computer date
    and display the current month's calendar (specialized with events),
    either on the same page or on a separate page?
    Any help would be appreciated,
    Cliff

    You can adapt this script to do that:
    http://www.valleywebdesigns.com/vwd_csscalhelp/vwd_csscalhelp_faq.asp#a5
    cliff man wrote:
    > As a page loads, is it possible to check the computer
    date and display the
    > current month's calendar (specialized with events),
    either on the same page or
    > on a separate page?
    > Any help would be appreciated,
    > Cliff
    >
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • Default value for variable are not within permitted value range (precalc)

    Hello BW community
    Issue:
    I have created a variable (Characteristic Value/ Manual input-default value) and use the precalculated value set (details-basic settings). In the further variable definition I could select the  precalculated value set in 'Default values', which I have defined beforehand in the broadcaster..
    The precalculated value set in the broadcaster settings is just based on a master data query on 0CUSTOMER.
    Error:
    The variable gets the error E991/R9E Errors: Default values for variable 'XXX' are not within permitted value range.
    The detail description of the error is: You defined default values for variable 'Sold-to party precalc value set for manuel input' that are not appropriate for the variable type; for example, a range is defined as a default value for a variable that only permits a single value.
    So please has someone had the same issue and found out how to solve it? It would be excelent to get good solution for this issue.
    Best regards and thanks
    Christian
    PS-1: System BW 701 / SAPKW70105
    PS-2 : there has been a SDN entry with the same topic but not resolved too.
    link: /thread/980839 [original link is broken]

    Hello,
    Thanks for your response.
    I should have mentioned that in my post. I tried this very first time. I thought that this is the place where you provide default value. But I got following exception at that time, so I thought, may be this is used for something else.
    <LifecycleImpl> <_handleException> ADF_FACES-60098:Faces lifecycle receives unhandled exceptions in phase RENDER_RESPONSE 6
    javax.faces.FacesException: javax.servlet.ServletException: OracleJSP error:
    oracle.jbo.NameClashException: JBO-25001: Object viewAllInd of type Control Binding Definition already exists.
         at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:415)Do I need handle something else when you put the default value?
    Thanks,
    Jai

  • HT2292 Have upgraded to itunes 11.0.1.12 start itunes and it is closed, message reads I tunes closed to help protect computer, data execution prevention has closed itunes. windows Vista 32bit

    Have upgraded to itunes 11.0.1.12. Start itunes and it is closed with the message itunes closed to help protect computer data execution prevention has closed itunes. operating system is ms vista 32 bit. I have followed the procedures that I can find on the itune support site.

    You're welcome. Glad you got things sorted out.
    (No problem about not spotting the solutions ... the most common causes of this sort of message changes over time, so it's not straightforward to be able to tell when a given piece of advice still applies to the symptoms. Definitely worth posting to try to get a current heads-up on the likely contemporary causes of a particular error message.)

Maybe you are looking for