Range Partitioning a table based on day of the week

I have a logging table which i want to partition into 7 partition, each one for the day of the week, eg MON,TUE, WED. I am aware and I can do a list partition by creating a parition key which stores 'DY' of the week and this means that I need to add another column to the existing table.
I wanted to explore the option of creating a range parition based on the timestamp column that already exists. Can anyone let me know if this option is possible?
Example
create table test_partition
( log_id number,
log_date TIMESTAMP(6),
log_value varchar2(100)
PARTITION BY RANGE (log_date)
PARTITION p1_mon VALUES LESS THAN (), ---- Not sure what can be used here to create this parition.
PARTITION p2_tue VALUES LESS THAN (),
PARTITION p3_wed VALUES LESS THAN (),
PARTITION p4_thu VALUES LESS THAN (),
PARTITION p5_fri VALUES LESS THAN (),
PARTITION p6_sat VALUES LESS THAN (),
PARTITION p7_sun VALUES LESS THAN ()
Any oracle guru with some suggestion for this would be highly appreciated..
Cheers,
VJ

Something like:
PARTITION P1_MON VALUES LESS THAN (TIMESTAMP'2009-03-10 00:00:00')
....Bear in mind that you will have to write a procedure to drop and create your daily partitions, and run that on a daily basis. Also you would be well advised to create a catchall partition that holds anything that won't go into your latest specified partition, eg:
PARTITION P_MAX VALUES LESS THAN (MAXVALUE)

Similar Messages

  • Background color based on day of the week?

    I have a column filled with dates going from 1-1-2007 to 12-31-2007. Using the autofill it was easy getting the dates auto-filled in. The only trouble with the overview is that's rather hard to see which days belong to the weekend, and which belong to the workweek (forgive my english..).
    Is there a way to automatically color the background of a cell, based on that specific data?
    If not, is it possible then to create a pattern? like 5cells green, 2 cells red, 5 cells green, 2cells red.. etc. you get the point.
    I thank you in advance for your help!

    I solved the problem it seems. I'll leave it for others with this trouble:
    In make case I just made the first two weekend cells Blue. I made a selection of these cells + 5 extra (the 5 days during the week). Then I just take the rightlower corner and start dragging to the lowest cell, overwriting the current cells, making them still appear the same but now with a 2 blue colored cells every 7 cells.

  • How to schedule in broadcaster based on Days of the week

    Hi Gurus,
    Using BEx broadcaster I have to schedule a report for Wednesday and Friday of every week.
    In the broadcaster I can se only the number of days, weeks and year.
    Please help out with a solution.
    Thanks
    Prasad

    Thanks!
    But I didn't undertand how to set it in broadcsater as there are no Weekdays mentioned.
    Can you please help out with the steps to do this?
    Thanks
    Prasad

  • Unique Auto Replies based on day of the week

    I want to setup auto reply rules similar to the Out-of-Office without having the user having to turn them on.  Additionally I want to set the rules to be at one time on weekdays, another on Saturdays, and a third on Sundays.  How can I set rules
    that do this?

    Hi,
    Sorry, we can't do this in Outlook, but you can repost in Outlook for Developer forum to confirm if we can achieve this goal using codes:
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev
    Best Regards,
    Steve Fan
    TechNet Community Support

  • Days of the week Record selection

    Hi All,
       I have 7 days of week boolean parameters for which when the user selects the date range, they can also filter which days of the week to use within that date range.
    Any ideas on how I can implement this in my record selection formula?
    Thank you in advance.

    Hi,
    You can make use of the DatePart formula
    The following formula will return which day of the week for a particular week.
    Eg:
    The field I am evaluting here Command.DocDate
    If I want to return Wednesday sales then I put in the following in record selection.
    DatePart ("w",{Command.DocDate}, crMonday) = 3

  • Range Partitioning for the day of the week

    I have a logging table which i want to partition into 7 partition, each one for the day of the week, eg MON,TUE, WED. I am aware and I can do a list partition by creating a parition key which stores 'DY' of the week and this means that I need to add another column to the existing table.
    I wanted to explore the option of creating a range parition based on the timestamp column that already exists. Can anyone let me know if this option is possible?
    Example
    create table test_partition
    ( log_id number,
    log_date TIMESTAMP(6),
    log_value varchar2(100)
    PARTITION BY RANGE (log_date)
    PARTITION p1_mon VALUES LESS THAN (), ---- Not sure what can be used here to create this parition.
    PARTITION p2_tue VALUES LESS THAN (),
    PARTITION p3_wed VALUES LESS THAN (),
    PARTITION p4_thu VALUES LESS THAN (),
    PARTITION p5_fri VALUES LESS THAN (),
    PARTITION p6_sat VALUES LESS THAN (),
    PARTITION p7_sun VALUES LESS THAN ()
    Any oracle guru with some suggestion for this would be highly appreciated..
    Cheers,
    VJ

    VJ,
    Here is an example of daily partitioning , let me know if this is what you want or you can modify this even to weekly, monthly, quarterly and yearly partitions.
    CREATE TABLE YY_EVENT
      PART_KEY       DATE                           NOT NULL,
      SUBPART_VALUE  NUMBER                             NULL,
      EVENT_NAME     VARCHAR2(30 BYTE)                  NULL,
      EVENT_VALUE    NUMBER                             NULL
    TABLESPACE TEST_DATA
    PARTITION BY RANGE (PART_KEY)
      PARTITION Y_EVENT_20090310 VALUES LESS THAN (TO_DATE(' 2009-03-11 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        NOCOMPRESS
        TABLESPACE TEST_DATA, 
      PARTITION Y_EVENT_20090311 VALUES LESS THAN (TO_DATE(' 2009-03-12 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
        LOGGING
        NOCOMPRESS
        TABLESPACE TEST_DATA
    )Regards

  • Oracle returning incorrect day of the week

    Hi there,
    I have a table named Performance, which includes a date field named PDATE, some other attributes such as title, etc, and a field named WEEKDAY, which includes the numerical value for the day of the week. Here is an example:
    PER#
    P#
    THEATRE#
    WEEKDAY
    PDATE
    PHOUR
    PMINUTE
    COMMENTS
    1
    1
    1
    1
    02-MAR-10
    19
    30
    Normal evening time
    2
    1
    1
    2
    03-MAR-10
    19
    30
    Normal evening time
    58
    6
    6
    3
    04-MAR-10
    19
    30
    Normal evening time
    5
    1
    1
    4
    05-MAR-10
    19
    30
    Normal evening time
    I went to verify the day of the week in a calendar (in fact I checked more than one) and I noticed that the Weekday value seems incorrect. For instance, the 2nd of March was a Tuesday so I would expect WEEKDAY to say 3 (considering Sunday to be the 1st day of the week, which is the universal norm), or perhaps 2 (considering Monday to be the 1st day of the week).
    First thing that came to mind is, since the WEEKDAY is a number field which has been pre-populated, the person who populated it made a mistake.
    So I went to verify this by running a query that would give me the correct day of the week by extracting it from the PDATE field:
    SELECT DISTINCT pdate, EXTRACT(year from pdate) year,
    to_char(to_date(pdate,'DD/MM/YYYY'),'DY') weekdaycalc, weekday
    FROM ops$yyang00.Performance
    ORDER BY pdate
    And to my astonishment, I got the following table as a return:
    PDATE
    YEAR
    WEEKDAYCALC
    WEEKDAY
    02-MAR-10
    2010
    SUN
    1
    03-MAR-10
    2010
    MON
    2
    04-MAR-10
    2010
    TUE
    3
    05-MAR-10
    2010
    WED
    4
    06-MAR-10
    2010
    THU
    5
    07-MAR-10
    2010
    FRI
    6
    08-MAR-10
    2010
    SAT
    7
    09-MAR-10
    2010
    SUN
    1
    10-MAR-10
    2010
    MON
    2
    As you can see, all of the above WEEKDAYCALC values are incorrect, and seem to match the incorrect values in WEEKDAY.
    I could perhaps understand some weird WEEKDAY numbering if there is some general database setting where I could specify any day of the week to be the first day. However, I can't think of any logical explanation on why Oracle would call a Tuesday Sunday.
    Could someone please advise what I mght be doing wrong? This is driving me insane!
    Thank you in advance for all the help and support.
    Regards,
    P.

    Hi,
    1bded5c7-e555-4306-ac86-45da83dff439 wrote:
    Thanks both Frank and Solomon for the help. I am quite new to Oracle and I feel you folks went the extra mile on the explanation
    Based on your explanations, I changed the formula so the date format would be processed as YY rather than YYY.
    SELECT DISTINCT pdate, EXTRACT(year from pdate) year,   
    to_char(to_date(pdate,'DD/MM/YY'),'DY') weekdaycalc, weekday   
    FROM Performance   
    ORDER BY pdate  
    And I got the correct values now:
    PDATE
    YEAR
    WEEKDAYCALC
    WEEKDAY
    02-MAR-10
    2010
    TUE
    1
    03-MAR-10
    2010
    WED
    2
    04-MAR-10
    2010
    THU
    3
    05-MAR-10
    2010
    FRI
    4
    06-MAR-10
    2010
    SAT
    5
    07-MAR-10
    2010
    SUN
    6
    08-MAR-10
    2010
    MON
    7
    The interesting bit here, is the original WEEKDAY field, which clearly has been created with the same mistake I did (this whole table wasn't created by me). I reckon I spotted a design bug.
    Regards,
    P.
    No; you're still calling TO_DATE on something that is already a DATE, and you're still using an implicit conversion (only now you're using a format such that the current NLS settings don't cause you to get punished.  If your DBA changes the NLS settings next week, then you will have similar errors again.)
    If you want to see what day of the week pdate is, then use:
    TO_CHAR (pdate, 'DY')
    or, to make it NLS-independent:
    TO_CHAR (pdate, 'DY', 'NLS_DATE_LANGUAGE=ENGLISH')
    This is simpler than what you posted, it's more efficient and easier to debug and to maintain, and it also gets the results you want in all cases.
    One more time: TO_DATE, as the name hints, converts something (a VARCHAR2, to be precise) TO a DATE.  If pdate is already a DATE, then what do you need to convert?  You're implicitly converting a DATE to a VARCHAR2, then explicitly converting that VARCHAR2 back to a DATE, and then calling TO_CHAR.  That's 3 function calls (1 of them error prone) where only 1 is needed.
    Also if you ever have to reconcile 2-digit years with 4-digit years (and, again, in this problem you don't) the correct way is to convert the 2-digit year to a 4-digit year, not vice-versa.
    Calling Tuesday the 1st day of the week could make sense in a particular application.

  • Formula for calculating the average takings for a given day in the week?

    I would like to calculate the average takings for each day of the week for a given financial year.

    Rick,
    I've looked at your document, made some additions and returned it to you. In your document you were not only using AVERAGE, but also MIN and MAX. Unfortunately, MIN and MAX don't have "IF" versions, so they can't be used to selectively operate on data matching criteria in a range.
    What I did to accommodate the need for MIN and MAX was to add a column for each criteria, in this case the different days of the week.
    In your document you also indicated the need for a Chart to graphically summarize the performance by day of the week. I rearranged your summary stats table to facilitate creating a chart from that table. I chose the mixed category chart with Bars for Min and Max and a Line for Average.
    Following are Screen Shots for the modified Data table, the Stats table and the Chart:
    The key expressions are:
    For Monday receipts:
    =IF(WEEKDAY($B)=2, $G, "")
    For Monday Minimum:
    =MIN(INDIRECT("Ledger::"&CHAR(70+ROW())))
    You had pre-filled Column A with 3-letter abbreviations of the Days of the Week. I am not sure this is important, since you could have formatted the Date (Column B) to show the same information, but I didn't like seeing the abbreviations for days that didn't have data entered yet so I replaced the text with an expression...
    =IF(LEN(B)>0, LEFT(DAYNAME(WEEKDAY(B)), 3), "")
    I seems that you may have filled the table with several months worth of rows of Mon, Tue, etc. Now, if you wish, you can trim the blank rows to just a few and add more as you need them.
    Let me know if you have any questions about maintaining the document.
    Jerry

  • Issue with Gregorian Calendar and setting Day of the week

    Hi
    This may have a simple solution, but its currently got me stumped. Basically, after some calculation I determine the date that a particular event should occur on. These events are listed in a JTable where the column headers are the dates of the beginning of the weeks. In order to place my calculated event in the correct column I create a Gregorian Calendar, set it to the date of the event and then set the day of the week to the beginning of the week. Normally this works fine but for a few instances, rather than getting the date at the beginning of the week, I get the date thats the beginning of the next week.
    As a quick example, to kind of illustrate my problem:
    I determine that the date of the event is 27/06/2006 which is a Tuesday.
    I want this event to appear in the column headed 25/06/2006, the date of the beginning of the week.
    In fact it appears in the column headed the 02/07/2006 which is the beginning date of the following week.
    Is there anyway to get it so when I set the day to the first day of the week it goes to the beginning of the current week rather than the beginning of the next week?
    Any suggestions would be gratefully recieved as I'm currently struggling to think of any.
    Thanks

    Hi, I dont say Monday is the begining of the week. At least I dont think I do.
    As for code I'll post the conversion bit which is:
    for (int i = 0; i < areaNameSelectionTable.getRowCount(); i++) {
    GregorianCalendar conversionCalendar = new GregorianCalendar();
    conversionCalendar.setTime((java.util.Date) prioritiesTable.getValueAt(i, 10));
    conversionCalendar.set(GregorianCalendar.DAY_OF_WEEK, GregorianCalendar.SUNDAY);
    }//end for loopI then create a string from the GregorianCalendar in the format DD/MM/YYYY and compare that with the headers of my table columns (Also dates in the format DD/MM/YYYY) When they match thats the column this particular event should appear in. I can post this code if necessary, but I dont know if its relevant.
    Thanks

  • Report Request - Tickets by day of the week

    So there are plenty of reports that show data based on past X days, but as far as I can see, none break it up into by days of the week.
    Example, For the last month, how many tickets were closed on Monday, Tuesday, by what Tech, in which Category/Location/Custom attribute.
    Could someone better than I make this happen?
    This topic first appeared in the Spiceworks Community

    I am not sure about your help.  Text variable is part of the header of a column and how is it possible to use the text variable as part of the result area.  I want the day to be part of the line item in the report.
    Appreciate if any one can provide their thoughts and input.
    Regards
    Sundar

  • Weekly schedule line should pass to last working day of the week in SAg

    HI,
    In a scheduling agreement when we have weekly or monthly schedules the system displays the date in the screen as 12/2010 or 13/2010 for say a weekly schedule.
    However when the data is stored in the table the delivery date is always the first working day of the week. In this case when the week is 13/2010 the data is stored in the table as 22/03/2010.
    Is there any way to change this to the last working day of the week?
    We have some config related to define delivery intervals in IMG--> Sales and Distribution --> Sales --> Sales Documents --> Scheduling Agreements with Delivery Schedules --> Define Delivery Intervals. Will this help solve my issue? If it solves what is the procedure behind this?
    Request you to provide your inputs.
    Thank You, Lakshmikanth

    Hi,
    Seems the delivery split concept is different from this requirement. Can Delivery intervals concept help us or not? IMG--> Slaes and Distribution --> Sales --> Sales Documents --> Scheduling Agreements with Delivery Schedules --> Control EDI Inbound Processing --> Define Delivery Intervals.
    What is the procedure and assignment details for delivery intervals concept?
    Thanks, Lakshmikanth

  • Getting first day of the week

    Dear All.
    As there is one function module BWSO_DATE_GET_FIRST_WEEKDAY which returns the first day of the week but its Monday but in our case we require Saturday and in some cases Monday.
    our user in UK are running the same report in which i have to calculate the stock base on starting day Monday and other uses are in KSA where the starting day of the week is Saturday.
    Is there any standard option available do achieve this.
    Kind regards,

    Hi Zeeshan,
    There are two options
    Option 1: In Routine or CMOD or in Variable use offset +5 or -2 according to your reporting requirements.
    Option 2: Maintain the table entries 52 Posting periods in T0009 or in custom table with special FISCAL Variant. (i.e., each week = one posting period). Have a loop up in that table according to your requirement.
    Hope either one of the option would help you in meeting your requirement.
    Best Wishes,
    BVC

  • Weekdays option in alarm does not correspond to first day of the week option in calendar

    I am based in Oman where the week is Saturday to Thursday and Friday is weekly off instead of Sunday. Inspite of changing first day of the week to saturday in calendar option and choosing weekdays option in Alarm, it rings on Fridays and does not ring on Sundays. Its very upsetting. Can anyone suggest a solution for this?? Thanks in advance.

    i just did this on my Blackberry curve 8330 to make sure my answer was correct, and what i was able to do was.
    Go to your calender, select the first day you would like it to start i i will start monday for example, Recurrence set to weekly. when selecting weekly another option will appear below it ( S M T W T F S ) highlight and select a letter that marks the day  Saturday , Monday , Tuesday Ect.  and the letting will become BOLD meaning it is selected. Thus giving you the option to select any , and as many days per week you wish, and have the recurrence as often as you want

  • 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

  • Payment terms - due date on a particular day of the week say friday?

    Experts is it possible in SAP payment terms to configure a term such that due date is on a particular day of the week?
    I want use payment term to determine due date for weekly billing cycle (sunday to saturday) for the invoice to be due on Friday net 27 days from mid point of the week
    eg 1. if a customer is invoiced any day between October 4th to 10th, the due date should be Friday Nov 6th
    eg 2. if a customer is invoiced and day between October 11th to 17th, the due date should be Friday Nov 13th
    Is this possible?
    Thanks in Advance

    You need custom development for this. Using custom development, Substitution in FI or User exit in SD
    I. FI Substitution -
       Create substitution with exit, for field day1 (BSEG-ZBD1T) and baseline date (BSEG-ZFBDT). In exit, determine number of days for required Friday from baseline date you want to use (say document date). This way, due date will be on Friday.
    For determining Friday, use calendar or Ztables.
    II. Invoices created in SD - If you are gerenating invoices in SD, use exit EXIT_SAPLV60B_008. This exit has table ACCIT which also has same fields Day1 and Baseline date. Follow same logic mentioned above.
    I hope this helps.

Maybe you are looking for

  • How to get LAST_VALUE from an Analytic Function within a report?

    My analytical report has following sql: SELECT.... DENSE_RANK() OVER (PARTITION BY pco.appropriation ORDER BY pco.appropriation, pco.fiscal_year ASC NULLS LAST) "Duration Years", SUM(pco.quantity) OVER (PARTITION BY sms.data_source ORDER BY sms.data_

  • Dynamic Actions in Report Fields

    Hello, i am upgrading my apps with dyn. actions. so my question. I want to enable or disable Fields in my report based on the value of a field in my report. example report shows: checkbox_|__name__|__ value ____ X __|__Mark__| <enable field> ________

  • Rec/client paramater for logging of table changes

    Hello all, I know that it was asked many times on many forums how to activate the log of a specific tables and most of the answers were about disabling every table activated by default through DD09L table and then use SE13 to enable the ones we want.

  • Music video/tv show problem

    i can't get my videos/tv shows on my ipod. it says my software is too old and i must update to 1.2. it won't even let me do this. i just want my videos on my ipod because i bought them all to watch on a 9 hour flight i am taking WEDNESDAY. somebody p

  • JLabel and JButton both disappear under Mac OS X

    Hello all, In my application I have two JButtons and a JLabel. When I compile and run the application the resulting window always shows the first button to begin with but doesn't show the second button until the window loses focus then gains it, or u