Calculate the last week of work

Hello

I use Oracle Database 11.2.1 and have a query that needs to filter on the date range of the last week of work. This must ignore Sat/Sun and works only on the days from Monday to Friday.

If I just use sysdate - 7 this will include weekends, can anyone suggest a better solution to take into account only the last work week (Monday to Friday)

Hello

sliderrules wrote:
... If I just use sysdate - 7 this will include weekends, can anyone suggest a better solution to take into account only the last work week (Monday to Friday)

So, if you run the query on Wednesday, May 15, you want that he only dates Monday, may 6 to Friday, may 10, inclusive; Isn't it?

If so:

WHERE   dt     >= TRUNC (SYSDATE, 'IW') - 7     -- 1 week ago Monday
AND     dt     <  TRUNC (SYSDATE, 'IW') - 2     -- the Saturday after thar

"Before Saturday' is identical to ' until and including Friday.
This is not your NLS settings.

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Since the output depends on the time of execution, after a couple of different run times and results you want to obtain the same sample for each run-time data.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}

Tags: Database

Similar Questions

  • Message: My windows Movie Maker has stopped working in the last week.

    Message: My windows stopped filmmaker working within the last week, began when the error message "the collections of file is not valid or is damaged. A new empty collections file has been created. When I try and import a file of any image type or otherwise, the file is not imported and the error message ends with "unknown error."
    So far WMM worked without fault, as full support has been removed for XP I am now unable to get all the patches. There is also no file conversion to allow to allow the import of files. Times, error message "class not registered"?
    What I'd really like is a copy of WMM version 5.1 (Build 2600 xpsp_sp3_gdr.101209 - 1647: Service Pack 3) Windows Movie Maker Version 2.1. 4028 0, I would continue with WMM, but am completely reluctant to upgrade to Windows 7. Someone at - he found a solution for the problem that I am facing.

    If you can open Movie Maker... try to go to... Tools / Options /.
    Compatibility on the left tab, click on the "all default settings"
    button / OK.

    Also... Do a restore of the system in Mode safe for a time
    before the problem started, may be worth a try.

    See the following articles:

    (306084) how to restore Windows XP to a
    previous state
    http://support.Microsoft.com/?kbid=306084

    How to restore a Windows XP system
    a previous state using system restore
    http://bertk.MVPs.org/

    (315222) a Description of the Safe Mode
    Boot into Windows XP options
    http://support.Microsoft.com/?kbid=315222

    How to start safe mode in Windows XP
    http://bertk.MVPs.org/html/SafeMode.html

    Good luck...

  • How to calculate this column (the last week of the month)?

    I have a request where it shows a few months of calculations of sage

    ex. This report is for Dec-2010

    statement line. A reduced rate. Approved rate. Last week declined the rate |
    -------------------------
    Asia report | ------20%----- | -----45%-------- | --------4%------ |
    Africa report | ------44% -----| -----21%-------- | ------12%-------|

    I'm figuring the column rate declined last week . The logic is simply not coming to my mind.
    Can someone suggest me how can I calculate this?

    We'll see. This report at any time after the previous month running has closed...

    (1) TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE) will give you the last day of the previous month.

    (2) TIMESTAMPADD (SQL_TSI_DAY, DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) *-1, TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) will give you the Saturday before the last week of the month.

    (3) TIMESTAMPADD (SQL_TSI_DAY, 1, TIMESTAMPADD (SQL_TSI_DAY, DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE)) *-1, TIMESTAMPADD (SQL_TSI_DAY, (DayOfMonth (CURRENT_DATE)) *-1, CURRENT_DATE))) will give you the Sunday of the last week of the previous month.

    Now that you have the start of the last day of the previous week, you can create your filter... It will be "(between 3) and 1)" above... "

  • For the last week or three Firefox updated two or three times for each update and sometimes for no apparent reason...

    For the last week or three Firefox updates two or three times for each update. Sometimes it refreshes without obvious reason. For example, I'll be in the middle of typing in the message forum block & it refreshes. Or by filling out an online form. Or simply viewing a page.

    You can check for problems caused by an extension that is not working properly.

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance).

    • Do NOT click on the reset button on the startup window Mode without failure.
  • HOW remove 'directionsAce' by myway of Chrome... it changed my home page and I can't get RID of it!  There is NO sign of it in the Applications, nor of any 'addition' what anyone new in the last week.  He hides.

    HOW remove 'directionsAce' by myway of Chrome... it changed my home page and I can't get RID of it!  There is NO sign of it in the Applications, nor of any 'addition' what anyone new in the last week.  He hides.

    The logo is still there.

    I worked all morning with directions from the web... and so far nothing has helped.

    Thank you

    It seems that you might have downloaded some malware or adware.  Download Malwarebytes Anti-Malware for Mac to get rid of him.  In the future, avoid the following types of sites to prevent it happening again:

    • XXX sites
    • torrent sites
    • Group download sites (CNET, Softonic, download (dot) com, MacUpdate, etc..)
    • MP3 download sites (Mp3 Skull, mp3monkey, etc.)
    • No matter what website says you can do or download something for free you know otherwise you would cost money
  • XPS 15 much warmer than usual, running for the last week

    I have a XPS 15 laptop with SSD drive and plenty of RAM which usually remains cool. Last weekend he installed an update of Windows 10 (I think it was the version 1607). Since then the fan worked upstairs while the laptop is turned on and it feels warmer than usual. The CPU load can be less than 20% for an extended period, but the fan continues to run. I managed to go back to the previous version of Windows and it has not changed.

    The only thing that worked partly is to limit the maximum level of the CPU at 50% (I tried to use this setting on the battery and then unplugged the laptop). This cut the fan at a lower level, but I never had to do before. So far, the fan would rarely work at all.

    What is going on? Do we need updated drivers?

    It's very strange. I was watching the new to-do Manager trying to figure out why it's so hot when the CPU load is 20%. Upstairs, he said Intel Core... @ 2.2 GHz. On the right, it indicates the maximum speed: 2.2 GHz. On the left, he said speed: 2.9 GHz (sometimes going up to 2.8).

    If I put the State of maximum CPU at 99%, it falls down to 2,18 GHz, if I put it at 100% it goes back up to 2.9 GHz. I don't remember what he showed before it started, but this sounds very wrong. In both cases it is going above 2 GHz, even if the processor is not much used, but I guess it's ok if it is not overheating. It is already cooled down in a few minutes and I'm waiting to see if the fan breaks down.

    Apparently he did this during the last week and a half. What happens here? Dell release a updated driver overclocked my CPU?

  • Calculate the last business day

    Hello

    I use Oracle Database 11.2.1 and wants to return to the last day of work (JJ/MM/AAAA).

    Working days Monday to Friday delivery

    for example on Sunday, 18 June 2000, the returned value would be Thursday, June 15, 2000

    sliderrules wrote:
    I wanted to say the days of the week

    for example, Monday, May 13, 2013 would return 10/05/2013
    Tuesday, May 14, 2013 would return 13/05/2013 etc.

    What the earlier query?

    SQL> with t as
      2      (
      3      select to_date('13/05/2013 ','dd/mm/yyyy') dt
      4      from dual
      5      union all
      6      select to_date('14/05/2013 ','dd/mm/yyyy') dt
      7      from dual
      8      )
      9      select dt,dt -
     10             case to_char(dt,'fmday','nls_language=english')
     11                         when 'sunday' then 2
     12                 when 'monday' then 3
     13                else 1
     14            end last_w_day
     15     from t;
    
    DT        LAST_W_DA
    --------- ---------
    13-MAY-13 10-MAY-13
    14-MAY-13 13-MAY-13
    
  • marking of documents created in the last week with the word 'NEW '.

    Hi all.

    I have a mysql database with a table 'articles' containing the following (and other) fields:

    • category_name
    • Date_Created
    • level_name
    • title
    • Summary

    I have set up a query to extract information on the statutes of the db. The questioning of basic works very well. It looks like this:

    $r = @mysqli_query ($dbc, $q);

    / * display the results * /.

    If ($r) {}

    while ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {}

    echo "< div class ="derniers_articles"> < strong class >: < facilities >". "." $row ["category_name"]. ' < br / > < strong > < em > posted on: < facilities > '. $row ["date_created"]. ' < br / > < level >: < facilities > '. $row ["level_name"]. "< /em > < h3 > '. $row ["title"]. "< / h3 > < class p ="last_ten"> < em >. $row ["Summary"]. ' < /em > < /p > < / div > ';

    }

    mysqli_free_result ($r);

    } else {}

    echo "< p > Prob get the info you need." < /p > ';

    }

    The query gives me result like this:

    Category: News
    Posted the: 2011-02-10 22:58:05
    Level: 5, 6

    Are you interested in politics?

    There are too many young people who don't is interested not in politics. It's a secret United Nations pay no one. However, this isn't the case of Darcy Lonergan who, at 21 years old, the youngest is launching itself candidates who pour win a seat in the next Parliament.

    Now, I want to mark all records created in the last week with the word 'NEW' so I inserted the line in bold in the following code:

    $r = @mysqli_query ($dbc, $q);

    / * display the results * /.

    If ($r) {}

    While ($row = mysqli_fetch_array ($r, MYSQLI_ASSOC)) {}

    echo "< div class ="derniers_articles"> < strong class >: < facilities >". "." $row ["category_name"];

    If (DATE_SUB (CURDATE (), 7 DAYS INTERVAL < = DATE($row['date_created']))) echo "< strong > NEW < facilities > ';"

    echo "< br / > < strong > < em > posted on: < facilities > '." $row ["date_created"]. ' < br / > < level >: < facilities > '. $row ["level_name"]. "< /em > < h3 > '. $row ["title"]. "< / h3 > < class p ="last_ten"> < em >. $row ["Summary"]. ' < /em > < /p > < / div > ';

    }

    mysqli_free_result ($r);

    } else {}

    echo "< p > Prob get the info you need." < /p > ';

    }

    .. but he throws this error:

    Parse error: syntax error, unexpected T_LNUMBER in [file path] on line 31

    31 is the "BOLD" line, I inserted. Can someone tell me what I am doing wrong? ("The date_created field is a timestamp like this ' 2011-01-08 18:06:39 '.)

    I'm new to php so be nice!...

    Thanks in advance.

    Hugh

    I think I'd be inclined to do in the query.

    By example SELECT field1, Field2, field3, etc, IF (DATEDIFF (NOW (), dtCreated)< 7,="" 'new',="" '')="" as="" recordstatus="" from="">

    Then echo just the value of the recordStatus for each record.

  • For the last week or so my app on my iPhone revel want updated. What's new?

    For the last week or so my app on my iPhone revel want updated. What's new?

    We solved that question revel iOS upgrade. Please see the details at:

    https://forums.Adobe.com/thread/1513106

  • When I try to open a bookmark I get a box that says: "that should make firefox with this file? When I try to change the 'open with Internet Explorer' I can't find firefox? This bookmark has worked well in the last week.

    When I open a bookmark a box appears that says "what should firefox with this file?" open with Internet Explorer? When I browse I don't find firefox to change. Last week this bookmark worked perfectly.

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).
    See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problems

    If this does not work in safe mode and then disable all your extensions and then try to find out who is causing by allowing both the problem reappears.
    You can use 'Disable all add-ons' on the start safe mode window.
    You will need to close and restart Firefox after each change through "file > exit" (on Mac: "Firefox > Quit")

  • My photos in lightroom now show in blue patches when I try to work with them. Did not have this before the last week or so and which does not in other programs.

    Does anyone else have this problem? Dark photos I have auto tone or trying to lighten the dark areas...

    Worked with these same photos before and didn't get it until the final weeks.

    Hi JeanStarling,

    Go to the histogram module developing Panel > choose "hide the Shadow clipping.

    Concerning

    Claes

  • HP 6730 b - update of results of the last week to atservice.exe put CPU @ 100%

    HP health check recommended to update the drivers of fingerprint digital authentic tec last week that I made.

    Now the flat atservice.exe lines 1 CPU at 100% and the fingerprint reader does not work.

    How can I tell what version I am running and how do I uninstall and install the old version?

    I solved it by going into Device Manager and do back the personal driver (under identification devices)

  • In the last week when I call a PDF file and print icon press that I get the button Save?

    With the help of Acrobat DC (last updated) with windows 7. Last week when I call a PDF via Amazon and press print icon, get the print with a button save page?  When I save the doc, I can print through this (different) window.  This happens with other sites that use PDFS.  Someone at - it a fix.  Talk to Adobe to YOU!  But, would appreciate help from anyone who is familiar with the issue.  See you soon!

    When you see the print dialog box, click on 'Change' of Destination and select your physical printer which is in this case HP Laser Jet.

    Here is the screenshot:

    Let us know the results.

    Thank you!

    Shivam

  • SQL to generate the last weeks date (not a stored procedure)

    I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.

    Varun says:
    I need SQL to generate the last dates of weeks from Monday to Sunday. I don't want to use the data in the table or the stored procedure. I need inline SQL. Please help me with your suggestions. Thanks in advance for the help.

    below should help you get started

      1* SELECT SYSDATE-LEVEL from dual CONNECT BY LEVEL < 8
    SQL> /
    
    SYSDATE-L
    ---------
    21-APR-13
    20-APR-13
    19-APR-13
    18-APR-13
    17-APR-13
    16-APR-13
    15-APR-13
    
    7 rows selected.
    
  • Calculate the fields do not work

    I am relatively new to work with Adobe Acrobat 9 Pro, JAVA Scripts, and PDF files. Though this may seem like a question of newby. I have a PDF file that has tons of fields which are populated under control of a database of the program. When the PDF file is made in my view to MVC, PDF rises and the fields display the correct values, but the fields that contain the total values are all zero (0). These calculate the fields I'm went to properties, calculate tab and then set the value set is (sum +), then chose the fields to be added. to test this, I put the default values of the fields to a 1 and on the ground, I began to calculate the sum shows the correct number. Then, I saved the PDF file and moved in my MVC file. When I run the program and say to the PDF, the PDF is called, values are met, and the PDF file will be displayed on the screen. Filled in all areas have the correct values but the field calculate display zero (0).

    The PDF file. You embed it in the form of script at the level of the document through Advanced - Document

    Treatment - Document JavaScripts.

    Make sure that it is not in function, but...

Maybe you are looking for