Simple question, finding last weeks final day (saturday) .

How would I find the system date minus a week and then find the last day of that week. This would be for a weekly report so it would need sysdate so nothing would need to be inserted. It should be ran any given day of the work week.
So today is the 11/29/2007 last week would be 11/22/2007 but the last day of that week is 11/24/2007. 11/24/2007 is the date i would be looking for if it was ran today.
How would i get this date. It has be a little perplexed even though I know it should be simple. I look forward to learning a thing or two.

That's mighty well done ..not so mighty as it could be.
Actually it is also NLS-dependant:
SQL> alter session set nls_territory='russia';
Session altered
SQL> SELECT SYSDATE -to_number(to_char(SYSDATE,'D'))-1 AS EOTPW FROM DUAL;
EOTPW
24.11.2007
SQL> alter session set nls_territory='america';
Session altered
SQL> SELECT SYSDATE -to_number(to_char(SYSDATE,'D'))-1 AS EOTPW FROM DUAL;
EOTPW
23.11.2007for finding the saturday of the previous week, the author can use 'IW' format model:
SQL> alter session set nls_territory='russia';
Session altered
SQL> select trunc(sysdate,'iw')-2 last_saturday from dual;
LAST_SATURDAY
24.11.2007
SQL> alter session set nls_territory='america';
Session altered
SQL> select trunc(sysdate,'iw')-2 last_saturday from dual;
LAST_SATURDAY
24.11.2007
SQL>

Similar Messages

  • Getting the data between Sunday and Saturday of last week.(DAYS NOT DATES)

    I have a stored procedure (that has no parameters right now) and does some extraction of data from different tables. One of the table has a column called 'DeliveryDate'.
    Based on the requirements, I have to create an SSRS 2008 R2 Report out of that stored procedure, so that users can see the data of last week from Sunday(Start DAY) to Saturday(End DAY). Even if it is Wednesday today, they should be able to see the data
    from Last Sunday to this Saturday. I don't want to get data of Monday, tuesday or wednesday. Also, these values shouldn't be STATIC. Meaning, if one user wanted to see deliveries on 04-15-2011, then he shoud see the values of the previous week (and NOT
    CURRENT week)
    1. Do I need to create parameters in my stored proc. Are they needed at all ?
    2. Should I use DateAdd, Datediff functions (If someone can explain, how will they be calculated!)

    to get last week sunday and saturday use below. I prefer to use parameters.
    set @startdate = DATEADD(wk,
    DATEDIFF(wk,
    0,
    getdate()),
    -2) --for
    sunday
    set @enddate = DATEADD(wk,
    -1,
    DATEADD(wk,
    DATEDIFF(wk,
    0,getdate()),
    -1))-- for saturday
    also
    refer the following link
    http://blog.sqlauthority.com/2008/08/29/sql-server-few-useful-datetime-functions-to-find-specific-dates/
    ESHANI. Please click "Mark As Answer" if a post solves your problem or "Vote As Helpful" if a post has been useful to you
    If I run the query on 5/4/2014, will it give me 4/27/2014 for Sunday and 5/3/2014 for Saturday? Meaning if I run it on a Sunday, it will give me the previous Sunday and not the current Sunday's date.

  • In CQ 5.4 how to read search trends(keywords) with in specific date (like last week, 30 days...)?

    I have a requirement to display popular search key words with in specific date range. Like search key words searched in last week/ in last 30days/in 90 days.
    how to get date range searched keywords from Search Trends?? is there any other way to get these??

    Issue was due to a syntax error. Case closed.
    Thanks!
    -OS

  • Inquiry quantity comparison with last week same day

    hi,
    i have a report to generate in BW, which needs to compare today's inquiry quantity with last week's same day quantity.
    for example. week2 monday comparison with week1 monday comparison.
    how to achieve in BEx to generate this report?
    regards
    venuscm

    Hi,
    Create two variables on 0CALDAY.
    1. For Current date
    2. For the correspodning date of the last week.( Same day as of current week)
    For the second variable , deduct 7 from the system date. it will give you the date of the same day in the last week.
    For e.g. system date is 10.05.2010 . and its a Monday.
    If you deduct 7 from the date it will give the date of the monday in the last week.
    Now create tow selection in the query structure one with current date variable and another one with the corresponding date of the last week.
    N compare them.
    Hope this will help.
    -Jaimin

  • Ref:iphone 3G.I was visiting the US last week.One day my iphone battery completely drained overnight.I re-charged it but ever since it has either come up with a message saying it's registering, or that I need to register it.It was registered years ago.

    Ref: iphone 3G. I was visiting the US last week.  My iphone battery completely drained overnight. I re-charged it but ever since it has either come up with a message saying it's registering or saying I need to register it.  I'm concerned that if I re-register it on itunes I'll lose all my data.  I originally registered it a couple of years or so back, when it was new.  Any advice much appreciated.

    Thank you for quick reply.  The data is still there - every so often when I switch it on, it comes up with the main icon screen, rather than the emegency calls only screen (which it does most of the time), and I can get to my contacts, photos, and so on, but it won't connect to any mobile/cell network provider, including my network here in the UK - O2.

  • Parameter for Last Week, Last Month & Last Year from the current Date

    I have a crystal report that has a StartDate & EndDate parameters from the stored procedure that I am calling. Now i got a new requirement saying that my user wants a drop-down parameter in which they need to be able to select last week (Sunday to Saturday), last month, last year instead of manually selecting start date and end date parameters? Can anyone please explain me how to do this?
    (FYI, I am using Crystal 2008)

    Hi Naveen,
    You'll need to handle the logic in the Stored Proc's where clause.
    If you're using oracle, I have something like this in the Stored Proc's where clause for our reports:
    Where {Date_Field} Between
    Decode('{?Relative Date}',
    'Yesterday', sysdate - 1,
    'Last Week', Tunc(sysdate, 'IW')-7)
    AND
    Decode('{?Relative Date}',
    'Yesterday', sysdate,
    'Last Week', Tunc(sysdate, 'IW'))
    where 'Relative Date' is a prompt in the Stored Proc and 'yesterday'. 'last week' are the 'static values' in the prompt.
    -Abhilash

  • HT201250 I've been working on a newsletter and have the final version. But I wanted to check something in a version I did last week. If I choose the day in Time Machine, is there any way I can view that document without "restoring" it to replace the final

    I've been working on a newsletter and have the final version. But I wanted to check something in a verssion I did last week. If I choose the day in Time Machine, is there any way I can view that document without "restoring" it to replace the final version?

    You can drag and drop a file from TM to the desktop.
    Let's say your newsletter is on the desktop. First thing to do is to add something to the file name, say Newsletter_1.
    Next open TM as if it is just another external drive by double clicking the icon. (This is not the same as "Enter Time Machine" which you do when you want to restore.) The file hierachy in TM follows the same logic as on your hard drive. Navigate to the date you want, find the file you want, and drag and drop it where you want it to be. Because you changed the name of the most recent version you can both files in the same space.
    I do this often.
    But remember if you make a back up now you will end up with both versions in TM.

  • HI I did not (nor did anyone in my household)purchace this app how can I get a refund? My ipod touch is a 3rd gen.so it does not have a camera.  I did buy a camera app one day last week only to find I could not use it.  This particular purchace was $1.98.

    HI,
    I did not (nor did anyone in my household)purchace this app how can I get a refund? My ipod touch is a 3rd gen.so it does not have a camera.  I did buy a camera app one day last week only to find I could not use it.  This particular purchace was $1.98.

    You can try contacting apple customer service http://www.apple.com/contact but usually all app purchases are final and not refundable.

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • HT201210 After asking a question last week, I now get scores of emails every day. I turned off the radio buttons on " notify me by email " respectfully please help

    After asking a question to the community last week, It now get scores of emails now with questions . I had marked the radio buttons to be notified but
    Later found them, and un clicked them all. Also I might have been hacked, because I was charged yesterday with an App, that I did not order!!!
    I only know that, because I get an instant message from my bank by phone, when I spend any money. I am worried.
    Bambi

    Hello Dorothea5916,
    It sounds like you changed your forum account preferences and now they have changed back, and you have an unauthorized purchase on your iTunes Store account and have concerns about your account security. I recommend first changing your Apple ID password with this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    Go to My Apple ID (appleid.apple.com).
    Click “Manage your Apple ID” and sign in.
    If you have two-step verification turned on, you'll be asked to send a verification code to the trusted device associated with your Apple ID. If you're unable to receive messages at your trusted device, follow the guidelines for what to do if you can't sign in with two-step verification.
    Click "Password and Security".
    In the "Choose a new password" section, click Change Password.
    Enter your old password, then enter a new password and confirm the new password. Click Save when done.
    The next time you use an Apple feature or service that uses Apple ID, you'll be asked to sign in with your new Apple ID password
    You should also report an issue with the purchase to the iTunes Store support directly with the following article:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/ht1933
    To enhance security for your account you may want to look into Two-Step Verification to help prevent unauthorized access to your account:
    Apple ID: Frequently asked questions about two-step verification for Apple ID
    http://support.apple.com/kb/ht5570
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • How to get the data for last 3rd business day and also include saturday and sunday if its a wednesday?

    Hi All,
    I have a simple query which is below:-
    Declare @reportdate date
    set @reportdate= (DATEADD(dd,-5,getdate()))
    select * from dbo.Table
    where date IN (@reportdate)
    I need this query to pull the data for the last 3rd business day .So lets say today is monday then i need the data for last week wednesday which is 3 business days back from monday, if today is a tuesday it would be for last thursday ( as 3 business days for
    tuesday would be thursday). But if today is wednesday then i need to be last 3rd business day which is last friday and i also need to get the data for saturday and sunday.
    Can someone please help me how cani change my filter to do this?
    Please let me know if i am still unclear.
    Thanks

    Hi SqlDev12,
    Based on my understanding on your requirement, you can reference the below sample.
    CREATE TABLE BusinessTable
    Bdate DATE,
    Wd VARCHAR(10)
    ;WITH Cte(DT,WD) AS
    SELECT CAST('20150401' AS DATE),DATENAME(WEEKDAY,CAST('20150401' AS DATE))
    UNION ALL
    SELECT DATEADD(DAY,1,DT),DATENAME(WEEKDAY,DATEADD(DAY,1,DT)) FROM Cte
    WHERE DT<GETDATE()
    INSERT INTO BusinessTable SELECT * FROM Cte
    SELECT * FROM BusinessTable
    SET DATEFIRST 7 -- Set Sunday as the first day of a week
    DECLARE @givenDay DATE ='20150415' --Wednesday
    SELECT * FROM BusinessTable
    WHERE Bdate BETWEEN
    --For Monday and Sunday, select last wednesday
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    --For Tuesday and Wednesday, last week's Thursday and Friday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3,4) THEN DATEADD(DAY,-5,@givenDay)
    --For Thursday and Friday, current week's Monday and Tuesday
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    --For Saturday, current week's Wednesday
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    AND
    (CASE WHEN DATEPART(WEEKDAY,@givenDay) IN(1,2) THEN DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay)-1,0))
    WHEN DATEPART(WEEKDAY,@givenDay) IN(3) THEN DATEADD(DAY,-5,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(4) THEN DATEADD(DAY,-3,@givenDay)
    WHEN DATEPART(WEEKDAY,@givenDay) IN(5,6) THEN DATEADD(DAY,-3,@givenDay)
    ELSE DATEADD(DAY,2,DATEADD(WEEK,DATEDIFF(WEEK,0,@givenDay),0)) END)
    DROP TABLE BusinessTable
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • I lost my iPhone 4 in Brussels last week. It was in airplane mode when lost. I also use a code to unlock the phone. The phone was off when lost. My question is: Can a person access my personal data on the phone?

    I lost my iPhone 4 in Brussels last week. It was in airplane mode when lost. I also had a code to unlock the phone. The phone was off when lost. My question is: Can a person access my personal data on the phone? Can they take the chip out and place it into another iPhone and access the personal info on the chip or is the personal data on the phone itself and could they put a new chip in and access the data?

    I have Find my iPhone App, but it says that it is offine.
    I've checked all week and it is offline.
    I clicked on erase iphone when phone accesses the internet on the Find my iPhone App.
    I just want to know how safe is my personal information that I have on that iPhone?

  • I want to know why some box of Iphone5s it's not come full accessories in box simple my iPhone 5s I have bought from Apple store last week it's first time for me use iPhone but so surprise me how the company make the phone have to use a pin to open

    I want to know why some box of Iphone5s it's not come full accessories in box simple my iPhone 5s I have bought from Apple store last week it's first time for me use iPhone but so surprise me how the company make the phone have to use a pin to open the sim but didn't give a pin inside the box and I ask staff at store their said they also don't know some box have some of are don't have a pin come together so then they told me I have to find solution or I have to buy a pin by my self I can buy it by myself but I really don't understand how come apple big company but how it's happen like this?thank you.

    Where did you purchase this. The US phones do not come with the SIM removal tool anymore. They haven't for some time now. I'm not even sure it comes with any of the devices anymore. You can just straighten out a paper clip and do the same thing.

  • Logged users for last week or last  7 days

    Hi in my application there is log for who is logging and i want to find who logged for last 7 days or last week.i tried the following query and its not workinghow to fix it
    select uid,agentid ,logtime from agnt_mst
    to_date(to_char(logtime,'dd-mm'),'dd-mm') between to_date(to_char(sysdate,'dd-mm'),'dd-mm') and to_date(to_char(sysdate,'dd-mm'),'dd-mm') - 7;

    Here trying for one test table
    desc emp_benefit
    employee_number varchar2(30)
    employee_name varchr2(40)
    dob date
    select distinct employee_number,dob from emp_benefits
    WHERE trunc(dob) >= trunc(sysdate-5)
    it shoud return
    70935     Mrs. Mervatte      17-AUG
    74552     Mrs. Dona      18-AUG
    75331     Mrs. Ramesh     20-AUG
    76068     Mr. Fernandes     17-AUG
    72366     Ms. Rajaa      19-AUG
    rgds
    raj

  • Find date if year, month, week and day is given

    Hi,
    How to find the date, if year, month, week and day is given?
    For example:
    Given, year - 2010, month - 03, Day - Wednesday, Week - 3,
    Then how can we get the date as 17-Mar-2010.
    Thanks,
    Chris

    with dt_tbl as (
                    select  2010 year,
                            3 month,
                            3 week,
                            'Wednesday' day
                      from  dual
    select  trunc(to_date(year || '-' || month || '-01','yyyy-mm-dd'),'iw') + (week - 1) * 7 +
              case day
                when 'Monday' then 0
                when 'Tuesday' then 1
                when 'Wednesday' then 2
                when 'Thursady' then 3
                when 'Friday' then 4
                when 'Saturday' then 5
                when 'Sunday' then 6
              end dt
      from  dt_tbl
    DT
    17-MAR-10
    SQL> SY.

Maybe you are looking for

  • Bluetooth icon in taskbar missing

    hi , just looking on my macbook pro and my bluetooth icon is missing form my top taskbar. checked its turned on and it is , is there a way to bring it back . any reason why it went ??? many thanks .

  • ITunes Not Download Music

    Hi my iTunes on my iphone 5c will only download certain music. Does anyone know what this could be or know how to sort it out. Thanks

  • SIGs/Workshops/Conferences

    I recently changed programming teams inside my company, and at last have a stipend for attending conferences, workshops, etc. My interests are (o'course) Java use in and with reference to: web services, XML, J2ME, XP, test driven development, and eme

  • Import 1.6.1.00.03 to 1.6.0.00.87

    just in case there's a chance it'll work... i've developed an htmldb 1.6.1.00.03 application and exported it to the sql export files. i was wondering if i could successfully import these files into an htmldb 1.6.0.00.87 instance? if this isn't possib

  • I get 2 Icons every time I down load

    IfI save anything to my desktop I have 2 icons. 1) is firefox document & 2) is files. It doesn't make any difference where I down load to, I end up with 2 icons. I have another PC and it does the same thing. Thank You