Query about previous days..Help needed

Hi,
I have a scneario in which I want to get the sunday's date for 5 weeks after today's date as
expiry date.
i.e., If this sunday is '14-Sep-08' expiry date will be '19-Oct-08'
(As it is 5 weeks ahead of the present sunday)
I am getting this as NEXT_DAY(SYSDATE,'SUNDAY')+35;
Now, I need to get the expiry date for the previous sunday.
How can I acheive this.
Thanks in advance.
Regards
Raghu

No, because it's easily doable with next day:
-- Next Sunday (excluding today if today is Sunday):
select trunc(next_day(sysdate, 'SUNDAY')) next_sunday from dual;
NEXT_SUNDAY
14/09/2008
-- Last Sunday (= today if today is Sunday):
select trunc(next_day(sysdate-7, 'SUNDAY')) last_sunday from dual;
LAST_SUNDAY
07/09/2008NB: If you're wanting next sunday to display today's date if today is Sunday, then subtract 1 from the date you're doing the next_day on, eg:
select next_day(to_date('14/09/2008', 'dd/mm/yyyy'), 'SUNDAY') next_sun_excl_today,
       next_day(to_date('14/09/2008', 'dd/mm/yyyy') -1, 'SUNDAY') next_sun_incl_today
from dual;
NEXT_SUN_EXCL_TODAY     NEXT_SUN_INCL_TODAY
21/09/2008     14/09/2008

Similar Messages

  • SQL Query Sorting Order issue - Help needed

    Hi All,
    I am using the following query in my project to display the records in the grid.
    /* Formatted on 04-09-2013 PM 8:01:51 (QP5 v5.149.1003.31008) */
      SELECT eol,
             status_msg,
             relation,
             building_name,
             device_id id,
             CEIL (SYSDATE - updated_date) duration,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_id_ref,
             LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_names,
             spname || '-' || ip_address || '-' || port AS child_asset_group
        FROM DEVICE_TESTBED_VW
       WHERE lab_id IN
                ('7099849',
                 '10769617',
                 '4258712',
                 '10513562',
                 '10515074',
                 '5882676',
                 '8330925')
    GROUP BY eol,
             status_msg,
             relation,
             device_id,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             building_name
    ORDER BY building_name ASC,
             LOWER (child_asset_group) ASC,
             LOWER (relation) DESC
    The problem is , if any one sorting with any column  , the order is not correct
    In this below code , i have done sorting by port . But the result data order is not correct .
    /* Formatted on 04-09-2013 PM 8:07:02 (QP5 v5.149.1003.31008) */
      SELECT eol,
             status_msg,
             relation,
             building_name,
             device_id id,
             CEIL (SYSDATE - updated_date) duration,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             TO_CHAR (updated_date, 'YYYY-MM-DD HH24:MI:SS') updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             LISTAGG (TESTBED_ID, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_id_ref,
             LISTAGG (NAME, ',') WITHIN GROUP (ORDER BY TESTBED_ID)
                AS testbeds_names,
             spname || '-' || ip_address || '-' || port AS child_asset_group
        FROM DEVICE_TESTBED_VW
       WHERE lab_id IN
                ('7099849',
                 '10769617',
                 '4258712',
                 '10513562',
                 '10515074',
                 '5882676',
                 '8330925')
    GROUP BY eol,
             status_msg,
             relation,
             device_id,
             lab_id,
             aisle_id,
             aisle_location_id,
             ip_address,
             port,
             slot_num,
             hostname,
             pid,
             description,
             sl_num,
             eitms_code,
             status,
             dnd_flag,
             aisle,
             aisle_location,
             spname,
             os_version,
             user_id,
             updated_date,
             isterm_svr,
             net_type,
             DEVICE_GROUP_REF,
             cmd_id_ref,
             building_name
    ORDER BY PORT ASC
    Can some one help me to fix this issue?

    Hi,
    Sorry, it's not clear what you want.
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved, so that the people who want to help you can re-create the problem and test their ideas.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    Simplify the problem as much as possible. For example, if you really need to GROUP BY 28 columns, post a problem where you need to GROUP BY only 2 or 3 columns.  (Just explain that you really have 28, so people will give solutions that are sure to work for all 28).)
    Always say which version of Oracle you're using (for example, 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • FLASHBACK QUERY - Range based - Doubt - Help needed -URGENT

    Hi,
    I want to user the flashback query facility to capture the history of versions for a day (i.e) i want to get the data versions from morning 10 a.m to 6.pm.
    How to get the versions by using the time range for a day.
    I used the query as
    select a.eno,
              b.eno,
              a.ename,
              b.ename
    from emp a, emp as of timestamp
    to_timestamp('08-NOV-2006 06:32:21.999999 AM','DD-MON-RRRR HH:MI:SS.ff6 AM') b
    where a.eno=b.eno
    The above query will fetch only one versions for the specified timestamp.
    How could i implement the range based search through flashback query.
    Please suggest any methods to implement the same.
    Thanks in advance.

    You'll want to read the documentation about Oracle Flashback Version Query.<br><br>
    Regards,
    Rob.

  • A very important question about the HostSample-Help needed!

    Hi,
    I'm trying to build a plugin for EM 12c ( 12.1.0.2 ) which suppose to monitor jmx mbeans .
    I encountered during the README file which was packed with the EDK .
    1. In the section where I try to use Flash builder ( ver 4.6 - that's the only release I found .. ) I folowed the instructions if how to run the example ( HostSample/HostSystem ) . When I run the example ( I installed the sdk's of Flash and everything that was written there - no problem )
    in the web browser i got the login page , and put the parameters ( username, password ) as it said in the README - the same username/password as i log in to the EM console .Than I got an error saying " ... RPC fault string ..... Logging to management server ... URL:https.. host ( my host name ) : port ( my port number ) /em..."
    Does anyone has a clue about this ? What am i doing wrong or miss something ?
    It is very important and urgent to me . please help .

    To add a bit more detail. Before you run the application from FlashBuilder, open the same browser you will use to run/debug the application in FlashBuilder and install certificate.
    Firefox:
    . when the "This Connection is Untrusted" warning appears
    . expand the "I Understand the Risks" item
    . click the "Add Exception..." button
    . on the "Add Security Exception" dialog, ensure "Permanently store this exception" is checked
    . click "Confirm Security Exception" button
    IE:
    . when the "Certificate Error: Navigation Blocked" page appears, click "Continue to this website (not recommended)"
    . click on the "Certificate Error" icon in the browser address bar
    . in the "Untrusted Certificates" popup, click "View Certificates"
    . click on the "Certification Path" tab of the "Certificate" dialog
    . select the root certificate (certificate at the root of the tree)
    . click "View Certificate..." button
    . click "Install Certificate..." on the "Certificate" dialog that appears
    . click "Next" on the "Certificate Import Wizard"
    . select "Place all certificates in the following store" button and click "Browse..."
    . select "Trusted Root Certification Authorities" on the "Select Certificate Stores" dialog and click "OK"
    . click "Next" button, and then "Finish" button
    . click "Yes" on "Security Warning" dialog that appears
    The other alternative is to enable http access using "emctl secure unlock". This is not recommended for a production site.
    .

  • PSE 7 confusion about folder location, help needed

    Here's some background: I'm using PhotoShop Elements 7 on Win XP.  I have an external firewire hard drive I use for overflow/backups.  Originally, this showed up as a K: drive on my system.
    I added a RAID controller and two more drives to stripe as a single drive for temp space rendering movies.  This ended up as a K: drive and the external moved to L:  However, when I did this there were some pictures from my catalog that I had on the external drive.  I have used File > reconnect missing files to handle the moves, but PSE is still confused (very).
    PSE has started to mix up the RAID (K:) and external (L:) content.  If I move a set of pictures (e.g. a folder of them) onto the external drive (L:) via drag and drop in the folder location view, the folder will show up empty on the L: heirarchy, but will show up as a gray folder icon in the K: RAID drive hierarchy.  If I open up windows explorer, the RAID drive will appear empty.  In other cases (I'm not sure when/how yet), pictures physically end up on the RAID drive itself instead of the external.  I have uninstalled both the external drive and the RAID drive and reinstalled them both, but they are still getting confused in the folder view by PSE.  I've also tried moving content outside of PSE and just reconnecting missing files, but it still wants to put things under the K: RAID drive instead of the external L:.
    I've searched everywhere I can think of for a description of what gray folder icons in the folder location view means and can find none.  I'm not sure how to convince PSE that there's nothing on the RAID K: drive and it shouldn't try to connect the two.  Any suggestions?
    Thanks,
    Jim

    Thank you!  I ran psedbtool and the output shows the catalog has the wrong drive letter for the L: drive.
    Is there a way to make PSE forget about the K: and L: drives that it is so confused about so that it can relearn of their existence?  If I use the drive letter reassignment to fix PSE, it will break other apps that are now dependent on the current drive letter assignments.  I've tried removing all files from the L: drive, but it's still remembered as part of the catalog.
    Thanks,
    Jim
    psedbtool version 1.07
    Opening catalog C:\Documents and Settings\All Users\Application Data\Adobe\Photoshop Elements\Catalogs\Moms pics\catalog.pse7db
    Photoshop Elements version:      7
    Total files               :   4833
    Total files missing       :      0
    Total files offline       :    278
    Total files wrong volume  :      0
    ****** Volumes with warnings: 1
    PSE Volume Table
    Path used by PSE        : F:
    Type                    : builtin_drive
    Status                  : online
    Total files             : 0
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : MEDIA
    Serial                  : 1C2F-9805
    Drive_path_if_builtin   : F:
    Id                      : 32520
    Path used by PSE        : M:
    Type                    : builtin_drive
    Status                  : online
    Total files             : 938
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : FreeAgent Drive
    Serial                  : 7830-2970
    Drive_path_if_builtin   : M:
    Id                      : 93626
    Path used by PSE        : E:
    Type                    : builtin_drive
    Status                  : online
    Total files             : 0
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : GAMES
    Serial                  : 025A-4B70
    Drive_path_if_builtin   : E:
    Id                      : 93625
    Path used by PSE        : L:
    Type                    : builtin_drive
    Status                  : online
    Total files             : 114
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : FreeAgent Drive
    Serial                  : 60AE-A816
    Drive_path_if_builtin   : K:
    Id                      : 31354
    ***** WARNING *****     : Wrong drive letter in catalog
    Path used by PSE        : \\dmzhost\media
    Type                    : network_drive
    Status                  : offline
    Total files             : 278
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : //dmzhost/media
    Serial                  : //dmzhost/media
    Drive_path_if_builtin   :
    Id                      : 26948
    Path used by PSE        : J:
    Type                    : builtin_drive
    Status                  : online
    Total files             : 3503
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : MEDIA2
    Serial                  : BAC0-B5A3
    Drive_path_if_builtin   : J:
    Id                      : 108
    Path used by PSE        : C:\Documents and Settings\All Users\Application Data\Adobe\Photoshop Elements\Catalogs\Moms pics
    Type                    : database_relative_drive
    Status                  : online
    Total files             : 0
    Total files missing     : 0
    Total files wrong volume: 0
    Description             : database relative
    Serial                  : amoc:database_relative_volume
    Drive_path_if_builtin   :
    Id                      : 2
    Windows Drives
    Drive  Type             Serial     Path
    A:     removable_drive  0000-0000 
    C:     builtin_drive    9088-07F9 
    D:     builtin_drive    F408-1CB0 
    E:     builtin_drive    025A-4B70 
    F:     builtin_drive    1C2F-9805 
    G:     builtin_drive    242D-15ED 
    H:     readonly_drive   0000-0000 
    I:     builtin_drive    427D-3F6B 
    J:     builtin_drive    BAC0-B5A3 
    K:     builtin_drive    64E8-9846 
    L:     builtin_drive    60AE-A816 
    M:     builtin_drive    7830-2970
    Thanks so much for your help!
    Jim

  • JPQL Query for specific usecase, help needed

    Does anyone knows how to write the JPQL query for this specific use case.
    Take 3 tables,
    Table 1 contains bids for many auctions (Bid table)
    Table 2 Contains many auctions (Auction Table)
    Table 3 contains many users (User Table)
    I need a query to retrieve all the highest bids per auction for a particular user.
    For example if the user has bidded on 10 auctions., but for each auctions has placed 3 bids each. Following the query, I would expect to get 10 bids back, each being the highest per auction.
    A Bid has a bid value that can be used for filtering.
    Thanks
    Peter

    It would be something like the JPQL version of 'select * from bids join auctions using (auction_id) where bids.userid = ? group by auctions.auction_id order by bids.amount desc'. But this is primarily an SQL question, and only secondarily a question as to how to translate that into JPQL, which should be straightforward.

  • Query using Group by - help needed

    I am having a query as follows:
    select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details where created_date = ' 22-Jul-08';
    As group by clause is missing it is giving errors.
    But when I add group by to this query, I have to add all selected values.
    How can I add the concatenatd values here.
    Is there any other way rather than writing as :
    (select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details where created_date = ' 22-Jul-08'
    group by id_nbr, stop_nbr, street || city || state)

    so where is the problem in writing:
    select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
    from details
    where created_date = ' 22-Jul-08'
    group by id_nbr, stop_nbr, street || city || state
    ????

  • Executing nested query contains ORDER BY:Help Needed

    I have a database in ORACLE 8.0 enterprise
    edition in HP-UX. I am trying to execute the following query
    "select * from ( select * from temptable order by value desc) where rownum < 5"
    and I am getting the following error
    "missing right parenthesis"
    This syntax is given in the Oracle user guide
    under sql commands section and it is not
    working.
    Similar query is working on Oracle 8.1 running on Win NT.
    Does any body throw some light.
    Thanks in advance
    -raj

    Your query works fine in Oracle 8i:
    SELECT *
    FROM (SELECT *
    FROM temptable
    ORDER BY value DESC)
    WHERE ROWNUM < 5;
    However, prior to Oracle 8i, in Oracle 8.0, it is not allowed to have an ORDER BY clause within a nested query. So, in Oracle 8.0, a query like the above cannot work. However, the following, with the ORDER BY clause in the outer query will work:
    SELECT *
    FROM temptable a
    WHERE 5 >=
    (SELECT COUNT (*) + 1
    FROM temptable b
    WHERE b.value > a.value)
    ORDER BY a.value DESC;
    null

  • My macbook pro says "the server encountered an error processing registration.please try again later." What does it mean ? i tried since the previous day. help me.

    my macbook pro says "the server encountered an error processing registered.please try again later."in facetime .what does it mean?

      Direct you to the proper forum for MacBook :
    MacBook Series Forums 
    https://discussions.apple.com/community/notebooks?view=discussions

  • Question about Airport..Help Needed.

    Hi, Ive successfully hooked up Airtunes, so my Itunes plays from my laptop, to my stereo. CAn i do this while watching a DVD on the DVD Player? So If I watch a movie on my computer, The sound will come out of my stereo?
    Thanks,
    Matt

    CAn i do this while watching a DVD on the DVD Player? So If I watch a movie on my computer, The sound will come out of my stereo?
    Unfortunately...no. (ref: http://docs.info.apple.com/article.html?artnum=304277#faq28)

  • About three days ago my ipod said i needed to sync and so i did . when i did it stop working and the wifi is grey out and says no wifi . Ive tried rebooting it , reseting , restarting but nothing seems to work . Can anybody help me ? Please !

    About three days ago my ipod said i needed to sync and so i did . when i did it stop working and the wifi is grey out and says no wifi . Ive tried rebooting it , reseting , restarting but nothing seems to work . Can anybody help me ? Please !

    Hello Philly,
    I believe that when you reset your ipod(command given from the computer, right?)  touch WHILE the ipod was updating, It cleared the system in the middle of writing files, thus corrupting(equivalent of cutting of in the middle of a sentence) the basic running system.
    I suggest you go to an apple store and ask for a technical diagonosis in person. they may offer to help if the problem is fixable. If your ipod is still under warrenty, i would guess it would be free/low cost.
    ~Remember, I am just giving an educated guess on limited information

  • Need sql querry for getting previous day records only

    Hi ,
    i have a table with following records,
    emp sal date
    111 200 03-mar-2011
    100 200 03-mar-2008
    15 200 06-mar-2012
    17 200 03-mar-2003
    178 200 03-mar-2004
    11 200 11-jun-2012
    i need only previous day records only(11 200 11-jun-2012).can any one help on this query?

    insa wrote:
    Except trun you can use Like operator--
    select * from emp where date like sysdate-1;
    Is it helpful for you?That is most certainly not a helpful answer. the LIKE operator is a string comparison operator and should not be used with dates. Doing so will cause an implicit date to character conversion based on the sessions NLS settings and would be not different to doing:
    select * from emp where to_char(date) = to_char(sysdate-1)... which will cause a lack of index usage, and also not deal with any time component within the date.
    Please ensure you test your answers before posting them. Several people had already given correct answers here with explanations as to why they are better than other methods.

  • Bex Query Get Qty of previous day

    Hello,
    I have a requirement and I'm not sure if it possible to design a bex query for it
    I have the stock data for each date.In my report I need to display the current day stock,previous day stock and the delta.
    The layout should be like below
                   Calendar day  01.01.2009    02.01.2009  03.01.2009 .........
    Stock                          |           200 |            350   |         425  |
    Stock previous day       |           100 |            200   |         350  |
    Delta                           |           100 |            150   |           75  |
    To get the current day stock is simple,it will just get the stock associated with that calendar day but to fetch the previous day stock i'm not sure how to set the fillter.
    Any suggestions please?
    Thank You.
    Edited by: A Pothuneedi on Apr 27, 2009 4:43 PM

    Hi,
    Select Stock Prv Day - Right Click--> Edit- now Find the Time dimension and Select CALDAY and drag drop right side.
    Right click on calday Select Restrict --> Select the variable which created move it to right side and give offset as -1. You will find offset setting above.
    Please do this and let us know if still have any issues.
    Reg
    Pra

  • Hi, i have purchased iPhone 5 about 15 days ago, its working well but only one problem that it has is that some time its losting signal and appear as no serves. would you please help me in this reqard. thanks

    Hi, i have purchased iPhone 5 about 15 days ago, its working well but only one problem that it has is that some time its losting signal and appear as no serves. would you please help me in this reqard. thanks

    Well, it could be that your carrier doesn't have a signal when it looses its signal.  You could try resetting network settings which might help - Settings/General/Reset/Reset Network Settings.  You'll need to set up any wi-fi networks you connect too again. If you're still having issues, contact your carrier.
    Good luck!

  • I wiped my Mac book Pro about 45 days by mistake ago and then when I started it up again after my apple ID wouldn't work on anything on my mac i.e. Aps store sign in, I tunes Sign in etc... can anyone help?

    I wiped my Mac book Pro about 45 days by mistake ago and then when I started it up again after my apple ID wouldn't work on anything on my mac i.e. Aps store sign in, I tunes Sign in etc... can anyone help? I dont know what to do...
    On the itunes store it says error 5002

    I had an issue where I had to wipe my mac as well. What you have to do to format the hard drive and reinstall is this:
    Restart the computer while holding down the option key. Choose the recovery disc. Find the main hard disc and hit format. Then you can reinstall Lion via the internet, it takes a while though, my computer took 5 hours or so.
    For your first question, if you got the family version of office, I believe you have 3 computers you can authorize it on. If you are not sure, look it up in the apple store.
    For the second: Time machine would probably be your best option, but I would reccomend restoring from a backup before you were having problems, and restore that one (put new files you need on another external or a digital-online storeage site such as dropbox.) To restore a backup, restart your computer and hold command+R and select "Restore from Time Machine Backup" (for more information go here: http://support.apple.com/kb/HT1427 )
    I don't believe tere is anything else you need to do, but I am new to macs, so I may not be the best source, but this is what I have found/have had to do.

Maybe you are looking for

  • Anyway to open .jpg attachments in the mail?

    Anyway to open .jpg attachments in the Gmail on IPad 3?

  • App. update thing 5800

    Hey guys. The thing is, i'm running out of memory in my 5800, i had 36 mb free in my phone and after updating to ovimaps 3.3 i have 30 mb, a there's still 15 mb to be updated, my question is, can i set the updates (im updating with the app. update)to

  • Change position of Columns in a JTable

    Hello together! I have the follow problem: I have a JTable and want to change the position of the Columns. I tryed to remove and add the columns but that doesn't really work, either I have no columns or I have all twice. If there is any better method

  • HT1338 i have a new mac air . the usb wont work and i cant charge my i phone with it

    please help me out . i have a new mac air . when i conect my cable to usb socket wont work . it wont charge my i phone either . whats wrong

  • I just migrated my old Mac to a New Mac.

    Now every time that something is deleted, it ask for the user pass code. Ran "repair disc permissions" did nothing. Also when the passcode is entered the item diappears but is not put in the desktop trash. Thanks