Interactive Reort with DATE logic

Hello

I have an interactive report with the following criteria.
Suppose the report is based on the EMP table and it has a date field called EMP_DATE

My earlier this week from Monday to Sunday.

* 1. Current week *.
01 Feb - Monday
Feb 05 - Friday
Feb 07 - Sunday

When I run the report daily from Monday (Feb 01) to Sunday (Feb 07), he must fetch all employees whose EMP_DATE is located between the current (Feb 01) week Monday & Friday (Feb 05).

* 2. Next week *.
Feb 08 - Monday
12 February - Friday
14 February - Sunday

When I run the report daily from Monday (Feb 01) to Sunday (Feb 07), he must fetch all employees with EMP_DATE between next week (Feb 08) Monday & Friday (February 12).

* 3. Previous week 3 *.
Jan 11 - Monday
15 January - Friday
Jan 17 - Sunday

When I run the report daily from Monday (Feb 01) to Sunday (Feb 07), he must fetch all employees whose EMP_DATE is located between the 3rd week previous (Jan 11) Monday & Friday (January 15).

If someone has implemented this type of logic?, appreciate your comments...


Thank you
Deepak

Hello

After a slight modification, you can go...

1.

WITH my_dates AS (SELECT TRUNC(SYSDATE)+LEVEL-20 dt
                  FROM dual
                  CONNECT BY LEVEL <= 20)
SELECT dt
FROM   my_dates
WHERE  dt BETWEEN NEXT_DAY(TO_DATE(:d)-7,'Monday')
          AND     NEXT_DAY(TO_DATE(:d)-3,'Friday');

2.

WITH my_dates AS (SELECT TRUNC(SYSDATE)+LEVEL-7 dt
                  FROM dual
                  CONNECT BY LEVEL <= 20)
SELECT dt
FROM   my_dates
WHERE  dt BETWEEN NEXT_DAY(TO_DATE(:d),'Monday')
          AND     NEXT_DAY(TO_DATE(:d)+4,'Friday'); 

3.

WITH my_dates AS (SELECT TRUNC(SYSDATE)+LEVEL-50 dt
                  FROM dual
                  CONNECT BY LEVEL <= 50)
SELECT dt
FROM   my_dates
WHERE  dt BETWEEN NEXT_DAY(TO_DATE(:d)-28,'Monday')
          AND     NEXT_DAY(TO_DATE(:d)-24,'Friday'); 

To integrate this into your reports, replace: variable d with trunc (sysdate) and dt with emp_date. Remove the WITH clause and you should be sorted.

See you soon

Ben

Published by: Munky on February 5, 2010 16:17

Tags: Database

Similar Questions

  • create form to load data to mysql with a logic of file download option

    Hello

    I have a question of logic:

    I was trying to create a form to upload data to mysql with a download of optional file (for a photo).

    The logic that I'm struggling with is that I can not understand how to deal with a failed validation. I can upload a photo to mysql with data (personal information) if the validation is ok. This part works fine. What does not work is I can't wrap my head around how code if lets say that the image is too big or bad format.  As I am I eventually save personal info and set a warning message that tells the user that there was a problem loading the file.  Let's say that the user wants to try again with the right type of file this time. the form won't let him try again because it would create a duplicate of the same user.  Should I code another query below my code that find the tis user and update the image instead? What is the best logic to process the download errors during the data already stored on mysql?

    I use the following to get rid of the spaces and symbols from the file names:

    ([preg_replace (' #[\s\&\@\#\$\%\(\)------[\] \ &] #', ", $imagename);

    I also use strtolower() change all characters to lowercase.

    My actual code would not help you because I use a PHP class to handle downloads.

    It's also a good idea to check the spirit of mime typesh FILEINFO_MIME_TYPE

    If your form processing is on the same page as the form (usually it would be at the top), what you can do is, after the insertion of the record, have the database to return the new identification number. Something like:

    $employee_id = mysqli_insert_id ($connection);

    Then you may have a hidden field in your form for the employee id:

    Then, when the form is displayed, check to see if $employee_id has a value and use an if/else statement to decide whether to INSERT or update.

    If (is_numeric($_REQUEST['employee_id']) {}

    UPDATE

    } else {}

    INSERT

    }

    For security on the data in the form, I use striptags() and bound parameters

  • Interactive report with Null columns

    I have a user who wants to export an interactive report, and there need to some columns will appear on export so that he can fill the data later (there is an intermediate step, while we work on getting all the data they need in the database). I created the report query, and there are a handful of columns null or empty (to keep the correct order for export). When I try to add this query to the APEX, in an interactive report, I get an "ORA-00001: unique constraint (APEX_040000.WWV_FLOW_WORKSHEET_COLUMNS_UK2) violated" error.

    Googling autour shows me that this happens because of the columns the same name, and the solution is to provide aliases for all columns. My report has alias on all columns, but I can't yet create an interactive report. I tried to change the columns null of empty strings, as well as encompassing the alias in double - quotes, but nothing works. However, I can use my original query to create a standard report, but due to export, this is not ideal.

    I was able to create the interactive report with a null and then edited the source column of the report to add to the others. This had to be done one at a time, given that you are trying to add several null columns at the same time gives the same error even once. Unfortunately, when I try and you run the page, I get a ' ORA-20001: get_dbms_sql_cursor error ORA-00918: column ambiguously defined "error.

    My original query:
    select customer.customer_name as customer,
           project.name as project_name,        
           trunc(project.estimated_end_dt) as due_date, 
           project_status.project_status_desc as status, 
           null as revenue, 
           project.baseline_effort as baseline_hours,
           null as projected_cost,
           null as est_gain_loss, 
           project.actual_hours as actual_hours,
           project.estimated_hours as projected_hours,
           null as projected_cost, 
           null as projected_gain_loss, 
           null as roi       
        from project, 
             customer
      where customer.customer_id = project.customer_id
      and project.inactive_ind = 0
      and project.customer_id is not null
      and project.estimated_end_dt >= :DTP_P50_STARTDT
      and project.estimated_end_dt <= :DTP_P50_ENDDT
    order by customer.customer_name, 
             project.estimated_end_dt;             
    Can someone tell me a way to create an interactive report with multiple null columns?

    Hi shimmoril,

    The problem is probably that you have two columns aliased as 'projected_cost' (columns 7 and 11).

    Hope this helps,
    John

    If you find this information useful, please indicate the 'useful' or 'correct' post so that others benefit. *

  • How to use the TRUNC function with dates in the expression builder in OBIEE.

    Hello
    How to use the TRUNC function with dates in the expression builder in OBIEE.
    TRUNC (SYSDATE, 'MM') returns 1 July 2010"where sysdate is July 15, 2010 ' in SQL. I need to use the same in the expression builder in the logical layer mdb column.


    Thanks in advance

    Use it instead:
    TIMESTAMPADD (SQL_TSI_DAY, (DAYOFMONTH (CURRENT_DATE) *-1) + 1, CURRENT_DATE)

  • Use thunderbird on several computers with data on server

    I want to use Thunderbird on my network home/office computers with data on a central computer. For the moment, I need to use mozbackup to transfer data from my desktop computer to laptop, which is a pain.

    Graeme

    As already mentioned, IMAP is the best method, but you can move the profile on the central computer folder and then have TB on each computer pointed to this location using the Profile Manager.

    http://KB.mozillazine.org/Moving_your_profile_folder_-_Thunderbird#Use_the_Profile_Manager_to_move_your_profile

    Another method is to copy a profile on a network share and start TB with command line arguments that specify the profile.

    3rd point: http://kb.mozillazine.org/Synchronizing_mail_on_two_computers

    There is a method of moving just the records of e-mail to another location:

    http://KB.mozillazine.org/Moving_your_mail_storage_location_%28Thunderbird%29

  • I recently updated my iPhone to iOS 9.3 6s and now my data and wifi are in place. Now I can't open the apps and send messages with data and barely on the wifi. I've tried everything, and it still does not work.

    I updated my iPhone to iOS 9.3 6s today and now my data and wifi are in place. Whenever I try to open an app or send text messages with data it does not at all. And with wifi, it just works. I tried just like turn roaming off and off and other lte but nothing seems to work at all. Can someone please?

    I have this same problem too, it really gets me upset

  • do you need a power supply to the current entry with data acquisition or 9265

    Hello I just receive the NI 9265 Daq for research in my lab. I'm trying to present entry and display it on an oscilloscope. I don't get anything. I did some research on the internet, so my question is do you need a power supply to the current entry with data acquisition or 9265?

    Read the data sheet.  Clearly on the first page is a sentence which reads "the NI 9265 requires 9 V to 36 V external power.

  • Make XY graph from the string with date and time data

    1 all sorry for my English.

    I have files with data. In this array of strings, I have 2 columns with date and time. I want to show these data to the XY Chart with time and date on some of the DBL and X on Y.

    I tried to do it by myself, but cannot add to time on X axis.

    Hi olderon,

    you date string is something like "30.01.2014" but looking for "%d//%m %y. Spot the problem?

  • I have a sony ericsson phone with data cable but cannot import pictures on pc

    I have a sony ericsson phone with data cable but cannot import pictures on pc

    I have a sony ericsson phone with data cable but cannot import pictures on pc

    =====================================
    When you connect via a USB cable... go to... Start / computer...
    the phone should be listed as a drive letter. You should be
    able to access photos from there.

    Also... If the AutoPlay window isn't launchng when the phone
    is connected... perhaps the following will provide some ideas:

    Windows Vista-
    How to change the auto run settings
    http://Windows.Microsoft.com/en-us/Windows-Vista/Change-AutoPlay-settings

    Windows Vista-
    Troubleshoot AutoPlay
    http://Windows.Microsoft.com/en-us/Windows-Vista/Troubleshoot-AutoPlay-problems

    Windows Vista-
    AutoPlay: Frequently asked questions
    http://Windows.Microsoft.com/en-us/Windows-Vista/AutoPlay-frequently-asked-questions

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • The default value for a property with data of type boolean

    Hi all

    Is it a system preference setting, where the default value for a property with data of type boolean can be a Virgin? I want to keep the value by default in a vacuum, but every time I save the property even after empty selection, the default value changes to FALSE.

    Capture.JPG

    In this case Boolean doesn't help you, you mayneed to create a chain of ownership and have true/false / "" as your list of values

  • Confusion with data sources / recordsets... ??

    I used to use Dreamweaver very strongly.  It has been a while, however, and now I'm loading up an old project that has been entirely developed "the way Dreamweaver" with games records and the use of extensions such as WebAssist gap.

    I opened Dreamweaver CC 2015.3 and I'm not finding anything on the Server Anywhere behaviors as I expected.  When I opened my pages that have the recordset data on them, or the shopping cart data, etc. I don't see all the windows of any place showing me that the data the way I used to see.

    I did a quick search in the help documentation and he said I should see a Panel under window-> links links, but I have no connections.  Don't know why... ??

    I did some digging and found a thread where it said that I had to install an extension, and it points me to a path for Windows Vista / Windows 7: C:\Program Files (x 86) \Adobe\Adobe Dreamweaver CC\Configuration\DisabledFeatures

    I'm on Windows 10, however, and I do not have a DisabledFeatures folder to the suggested location.

    I'm also confused why this would be an extension at this point... ??  Recordsets has been one of the most powerful features of Dreamweaver (I thought).  How am I supposed to my configuration database connections and to create and manage the data of the database now?

    More importantly, how do I get my old project works in the same way that he used?

    Any information on this would be greatly appreciated.  Thank you!

    Adobe dropped their Director Extension of development in 2015.

    Here are 3 freebies that you can use to install 3rd party extensions.  I used all the success.

    Anastasiy extensions Manager

    http://install.anastasiy.com/

    The seven extensions of the project manager

    http://www.Projectseven.com/extensions/

    The DMX Zone extensions Manager

    http://www.DMXzone.com/go/22670/DMXzone-extension-manager-for-Dreamweaver

    Replace deprecated server behaviors with a modern commercial extension:

    To work with data Dynamics and PHP, you need a local test server.

    See setting up a PHP environment in Dreamweaver

    http://www.Adobe.com/devnet/Dreamweaver/articles/setup_php.html

    Nancy O.

  • How to generate the display of mobile list with data of the user

    I try to develop a simple mobile application (mobile jquery) in Dreamweaver.

    I want to create a list of names of people from entering information via a form.

    The list would then be based on criteria that is last name or Department

    This require additional database programming or it is part of jquery mobile?

    I know it sounds simple, but I'm not a programmer, so I'm just my feet wet here.

    Thank you

    DW has no capability of database currently.  If you do programming server side with PHP and MySQL, there are commercial extensions, you can buy separately from the Web help and area of DMX.  But it's all depends on you how to work with data MySQL & PHP.  Development of applications for mobile devices is still a different learning curve.  I think DMX Zone has some extensions to help with that as well.

    http://www.DMXzone.com/go/32214/mobile-app-development/

    Nancy O.

  • Help with date required

    Hello

    I have two columns with the date and the other with time, but both are vchart2.

    What is the best way to convert a column of actual date

    or add a column with the effective date and fill it with data from the first and second column

    in the format (12 October 2013 10:31:11 ', JJ 24HH:MI:SS)?

    Thank you very much

    Hello

    user9223521 wrote:

    ...  You're right, that a space between column1 and column2 is useful.

    I do not think that a space it is useful, but if you think it is, go ahead and add - we.  The important thing is that the data in the 1st argument to TO_DATE having match format in the 2nd argument.  If there is no space between the year and the time in the 1st argument, then do not use a space between the year and hour in the 2nd argument.

    This code is not convert the column or add a column? ...

    It's true.  Replace the 2 columns existing VARCHAR2 with a DATE column is a good idea.  Here's a way to do it:

    1. Use ALTER TABLE to add a new column (let's call it entry_dt.  You cannot use the same name as one of the existing columns.)
    2. UPDATE the table using TO_DATE as shown above, to set the value of entry_dt
    3. Use ALTER TABLE to drop the old column1 and column2
    4. If you want to rename entry_dt to one of the old names of columns, use ALTER TABLE to this

    If you have incorrect or invalid data, then step 2 fails.  See

    Re: How to select valid dates only

    of the means to detect bad data without triggering an error, then you can fix before the UPDATE, or ignore it all by doing the UPDATE.

  • animate interactive icon with a privilege .oam on edge

    Hello all the world I meet muse on a problem, I hope you could you help me come.

    I make a lively and interactive icon with a link to a page of the site on edge animate with a .oam rendering for use on muse. When I test it on the browser, the link works fine, however a liver on muse, send the link appears only in the square of the "icon. I don't know where my mistake help me is it you please.

    OAM - is a site within the site, located inside an iframe. Therefore, the button can be used only as _blank, _self not OAM. You must change this in edge animate and re-export OAM

  • I need to merge a form with data in Excel, how can I do?

    Hello, I use a form to fill out on-line the Government and need to fill it with data in Excel. How can I do?

    Thank you very much.

    MY

    This type of operation is called a mail merge. It can be done using the PDFMaker plugin in (some versions of) Office, or by using a script.

    The names of the columns in the Excel file must match the names of the fields in the PDF file, however.

Maybe you are looking for