Finding the Weekend dates if its starting day of the week

Hello FOlks,
I have this requirement where if the sysdate is monday i need to get the Data from Friday until Sunday i.e. sysdate -3 to sysdate -1
Otherwise i need to get the previous day data. How can we acheieve that for below query based on created date??
select c.client_code,
e.created_date,
        c.client_name,
   from event_client_field ecf, event e, client c
  where e.event_id = ecf.event_id(+)
    and e.client_id = c.client_id
    and trunc(e.created_date)
   = trunc(sysdate - 1)Edited by: user11961230 on Feb 1, 2011 10:01 AM

Hi,
So, you want to do one thing if today is a Monday, and you want to do something else if today is not Monday.
That sounds like a job for CASE:
select c.client_code,
e.created_date,
        c.client_name,
   from event_client_field ecf, event e, client c
  where e.event_id = ecf.event_id(+)
    and e.client_id = c.client_id
--  Nothing above this line was changed; everything below was changed
    and e.created_date >= TRUNC (SYSDATE) - CASE  TO_CHAR ( SYSDATE
                                                           , 'DY'
                                     , 'NLS_LANGUAGE=ENGLISH'     -- If necessary
                                 WHEN  'MON' THEN  3
                                 WHEN  'SUN' THEN  2     -- If wanted
                                            ELSE  1
                             END
    AND e.created_date < TRUNC (SYSDATE)
;Whenever you have a condition, try to use the raw column from your table as one of the operands instead of expressions based on the column. That is, try to say
AND e,.created_date < ...   rather than
AND TRUNC (e.created_date) < ...   That way, the optimizer can use an index on e.created_date, and it could be much faster.

Similar Messages

  • Query to get weekending date(friday) using any day in a week

    Hi,
    I need to get week ending date for the date within a week. ex: if gl_date =4/17/2013 then based on this date weekending date should generate and it should be friday of that week i.e 4/19/2013
    how can I write query for that?
    Appreciate you for your help.

    Hi,
    Bencol showed how to do this, assuming that for Saturday and Sunday, you want the previous Friday.
    If you want the following Friday for all days (except Friday itself), then change Bencol's formula like this:
    TRUNC ( gldate + 2
          , 'IW'
          ) + 4The "magic number" 2 reflects the fact that the ISO week ends 2 days after your week ends. (ISO weeks always start on Monday and end on Sunday, regardless of you NLS settings.)

  • TS1347 Dear apple, The governments of Saudi Arabia has changed its weekend from THR&FRI to FRI&SAT, Therefore the start day of the week became SUN. unfortunately all Iphone user could not adjust this change on their I phones . So will you  please facilita

    Dear apple,
    The governments of Saudi Arabia has changed its weekend from THR&FRI to FRI&SAT,
    Therefore the start day of the week became SUN. unfortunately all Iphone user could not adjust this change on their I phones .
    So will you  please facilitate us on this matter.
    Regards

    Give apple feedback regarding this.
    For a temporary fix, change your region? Get a 3rd party Calendar app that fits your needs?
    I assume your current region is set in the photo?
    If so, pick a region that has a start day of Sunday. (either historically or known for the present)
    Note, with changing your region, it will change the default phone number prefix/country code for new contacts and addresses. (calling and SMS is not affected)

  • I am trying to find out if I can change a setting of the calendar in my iPhone.   When I view calendar, in month, I would like to view it with the starting day of the week being Monday, not Sunday.  Is it possible to make this change? SS

    I am trying to find out if I can change a setting of the calendar in my iPhone. 
    When I view calendar, in month, I would like to view it with the starting day of the week being Monday, not Sunday.  Is it possible to make this change?

    Hello SMEvans32
    You can use iCloud to share the Calendar, that way she will always be up to date on that particular section of your work calendar. If you want to use iCloud, I would recommend backing up so you have a safe copy of your data.
    iCloud: Calendar sharing overview
    http://support.apple.com/kb/PH2689
    iCloud Setup
    http://www.apple.com/icloud/setup/
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Rolling 30 Day Calculation Based on the Weekend Date

    Hi Guys,
    I am trying to calculate a sum of rolling 30 day based on the weekend date. The table I am going to query has a date column that only has weekend date(Saturdays only). Based on that I have to calculate the formula for rolling 30 days. I am using the formula to RelativeDate formula to do this calculation.
    ToDate(FormatDate(RelativeDate(CurrentDate();-DayNumberOfWeek(CurrentDate() -  this formula is to get the last Sat of the week.(Previous Week)
    =RelativeDate([Previous_Week];-30) This is to get the rolling 30 days based of the last Saturday of the week.
    Here is where I face the problem and would need your suggestion -
    when I do a sum using the previous date and rolling 30 day I am getting an error
    =sum([Acc]) Where [Week Ending] Between([Previous_Week];[Rolling 30 Days])
    Error-  Missing or bad operand in Where expression.
    Is there any other formula I could use?
    Thanks for your help in advance,
    Jitan

    Hi,
    You are missing paranthesis () in your formula. Try using
    =sum([Acc]) Where ( [Week Ending] Between([Previous_Week];[Rolling 30 Days]) )

  • Hey ppl,my macbook is not booting and by that i mean u can hear the audio wave when its starting up,the screen goes white and then after a while there's a folder with a question mark in the middle of the screen...anyone,any ideea?!?

    Hey ppl,my macbook is not booting and by that i mean u can hear the audio wave when its starting up,the screen goes white and then after a while there's a folder with a question mark in the middle of the screen...anyone,any ideea?!?Regards.

    That folder with the question mark icon means that the MacBook can't find the boot directory. That can either mean it can't find the hard drive or the hard drive data is somehow corrupted.
    Put your install DVD into the drive and reboot. As soon as you hear the boot chime, hold down the "c" key on your keyboard (or the Option key until the Install Disk shows up). That will force your MacBook to boot from the optical drive.
    Once it has finished booting and you are at the Install screen launch Disk Utility from the Utilities menu. Is your Hard Drive in the list on the left?
    If it is then select the First Aid Tab run Repair Disk and if that repairs any problems run it again until the green OK appears and then run Repair Permissions.
    If your hard drive isn’t recognized in Disk Utility then your hard drive is probably dead.

  • Is there a way to change the start day for the week?

    So I really like the "Insert Categories from the following" functionality of the Reorganize tool, and I fell in love with it's ability to break down by date automagically. I've encountered one problem with my use of it, though: I start my "work week" on Sunday, and it defaults to Monday as the first day of a week without any seeming way to change it to Sunday. Is there a way to do this?

    Hi Christopher,
    The WEEKDAY function allows specifying either Sunday or Monday as the first day of the week:
    WEEKDAY
    The WEEKDAY function returns a number that is the day of the week for a given date. WEEKDAY(date, first-day)
      date:  The date the function should use. date is a date/time value. The time portion is ignored by this function.
      first-day: An optional value that specifies how days are numbered.
    Sunday is 1 (1 or omitted):  Sunday is the first day (day 1) of the week and Saturday is day 7.
    Monday is 1 (2):  Monday is the first day (day 1) of the week and Sunday is day 7. Monday is 0 (3):  Monday is the first day (day 0) of the week and Sunday is day 6.
    But I think you are referring to the first day of the 'workweek', for which I do not see a means of defining a custom value.
    Since you want to 'insert categories', though, you could easily define your own, using WEEKDAY(date) or WEEKDAY(date,1), plus an IF statement to return the category label appropriate to the day. Here's one for a Sunday to Thursday work week. Dates are in column A, the formula is in whichever column you want as the Category column. For the example, I've placed it in column B.
    B2, and filled down: =IF(WEEKDAY(A)<6,"Work","Off")
    The top table shows the weekday numbers returned for each day of the week for each of the three permitted values for the optional second argument. The bottom table shows the results from the formula above, used to define a category label for each date:
    A10 was left blank intentionally, to determine if the lack of data resulted in an error. The Warning message, flagged by the blue 'warning' triangle, is "The formula uses a number in place of a date." The 'date' assigned to this numerical value of zero was a Friday, but I'm not certain when. Probably best to avoid extra rows with no date shown.
    Regards,
    Barry

  • I'm moving an internal hard drive from an old computer to a new computer.  How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?

    I'm moving an internal hard drive from an old computer to a new computer.  (My new compute runs Windows 8.1) How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?  Is this possible or do I have to use the procedure of copying the catalog along with the photos to a back up hard drive and then restore them on the new computer?

    The 'normal' procedure is to do a PSE organizer backup (not a copy or a backup from external tools) to an external drive, then a restore to the new location.
    The advantage is that you have a backup of both catalog and media files and you don't have all disconnected files, which would happen with external backup tools. Also, if you restore with a more recent elements version, the catalog will be automatically updated to the new format.
    The drawback in your situation is that you'll have either to overwrite all your files or restore to a custom location, creating a duplicate photo library (which supposes you have enough free space).
    It would be possible to simply use the organizer in the old PC to move the catalog to a new 'custom' folder just under your C: root drive. The catalog would be accessible once the drive will be installed in the new PC. Then you would have all files 'disconnected' due to the fact that all your media files are now on a drive with a different letter. Reconnecting a whole library is a hard job with PSE6, less so with PSE11/PSE12.
    If the idea of fiddling with the sqlite database with external sqlite manager tools is ok for you, I can describe the process more in detail. You only copy your catalog folder (as suggested above) to another location. Instead of trying the 'reconnection' way, you install the sqlite utility on the new computer. When the old drive is installed in the new computer, you simply edit a given record in the catalog database, catalog.psedb, and start the organizer with your copied catalog by simply double clicking the 'catalog.psedb' file.
    Even if the last solution is much, much quicker, I would still create a new PSE backup : you have never too much safety .

  • Function module for getting starting day of a week form current data

    Hi ,
    Is there any function module that gives starting day of week when we give a particular date
    eg: today date is 19-12-2007
    if i give this date as input i should get 16-12-2007 because this is starting day of this week .

    Hi,
    Use FM  GET_WEEK_INFO_BASED_ON_DATE
    You will get the first day of the week in export parameter MONDAY
    Lokesh

  • HT1657 If I download a movie today, but will not be watching it for a few weeks (i.e. when overseas) - when does the 'activation' period start?  Do I have 48 hours from the download date or when I first watch the movie?

    If I download a movie today, but will not be watching it for a few weeks (i.e. when overseas) - when does the 'activation' period start?  Do I have 48 hours from the download date or when I first watch the movie?

    You have 30 days from when you download it, but when you then start watching it you have 48 hours (24 if your account is US based) to finish watching it before it expires.

  • I pre-ordered an iPhone 6 Plus and the delivery date now says October 14th. The point of the pre-order is to get it on release day (or shortly thereafter). Can I go to a Verizon store to pick up my new phone on release day?

    I pre-ordered an iPhone 6 Plus and the delivery date now says October 14th. The point of the pre-order is to get it on release day (or shortly thereafter). Can I go to a Verizon store to pick up my new phone on release day?

    I'm not sure that answers the question Candice.
    I'm in the same situation.  I was up trying to get on the Verizon page at 11:55, kept getting the ECPD error.  When finally got through, the Silver Iphone Plus 64 showed arrival of 9-19.  At every step of the process, it seemed that I was ordering a phone that would arrive on day1.  At no point did it say this was an estimate.  At no point did it say it might change.  In a big yellow box, it said "9-19".  Ordered it, then got confirmation email stating it should arrive at 9-19.   Seems like all should be good, right?  Order site said 9-19, I've got a confirmation email saying 9-19, done and done.
    Then I check the website, and suddenly it changed to 10-14?!?!?!?  I feel like this was a bait and switch.  I was able to pickup an iphone5 in a local store on launch day, and would not have locked myself into a preorder through Verizon if I had known this would happen!
    So, that leads back to the original questions.  Lets assume I walk into a Verizon store on 9-19, and there is an available iphone6 plus just sitting there, can I either get that phone as fulfillment of my pre-order.  Or, cancel my pre-order and buy that phone right then and there?
    JJK
    PS:  It seems there are many people you misled this way.  For every person who takes the time to post on this site, there are going to be many many more who are silently ****** off.

  • APO-SCM5 Configuring the Start Day of the week (e.g., Monday)

    Where can we configure the start day of the week (e.g., Monday or Sunday).  When we release DP to SNP, order category FA=FC Reqs are falling on Monday.  I am being asked where this is set at we have seen disturbing results where some location-producta have FC Reqs on Monday and some Sunday.  We are trying to determine if there is some sort of bug in SCM 5 as in APO4.0 all FC Reqs fell on a Monday at time= 00:00:00
    Message was edited by:
            Dan Spieth

    Hi,
    You can use planning calendar (T.code md25) to define the start of the day Eg:mon/tue/wed etc.
    Regards,
    SDS

  • Regarding Start day of the week

    Suppose in a program if User enters the start day of the week be 'Tuesday', then I have to get that day of the week as '1' and end the week with 'Monday' i.e the '7'. Is there any Query or NLS_Parameter setting?

    Hi,
    Since Tuesday is 1 day after the start of the ISO week,
    TRUNC (dt) - TRUNC (dt - 1, 'IW')will be an integer in the range 1-7, where 1 means dt was a Tuesday, and 7 means dt was a Monday.
    This does not depend on NLS settings.
    NLS_TERRITORY controls which day of the week
    TO_CHAR (dt, 'D')will be '1', but all the settings I know of make that Saturday, Sunday or Monday. I don't know if there's a value that makes it Tuesday.

  • Change Starting Day of the Week to Sunday

    Hi,
    DBMS_SCHEDULER is assuming that Monday is the starting day of the week.
    Can this behavior be changed ? I need Sunday to the be starting day of the week.
    Regards,
    Salim

    So to start at 8am on sunday :
    start_date => next_day(trunc(sysdate),'Sunday') + 8/24OR
    begin 
    dbms_scheduler.create_schedule 
    (schedule_name => 'INTERVAL_DAILY_800', 
    start_date => next_day(trunc(sysdate),'Sunday') + 8/24,
    repeat_interval=> 'FREQ=DAILY; BYDAY= SUN,MON,TUE,WED,THU,FRI,SAT; BYHOUR=08;', 
    comments=>'Runtime: Every day (Sun-Sat) at 08:00 o'clock');
    end;
    /Best Regards
    mseberg

  • How can I change the start day of the week for weekly view?

    How can I change the start day of the week for weekly view?
    <P>
    This function is configured in the code in file <loadpoint>/CalendarServer/cal/uicust/en/main.html:
    <P>
    i18n['def first day'] = '1';
    <P>
    Note: 0 is Sunday, 1 is Monday, etc.

    Click system perferences below ur screen then click language&text and you just select ur peference langauge

Maybe you are looking for