Two date column in a table

I have a Sales Data warehouse of Retail shops which operate 24x 7 with 2 shifts of 12 hours each. Time for each shift is 7 to 7.
I have a Calendar Dimension which has all the dates listed.
TABLE_CALENDAR
-DAY_KEY NUMBER
-DAY_DATE NUMBER
I have a Sales table which has two dates columns: one is the Sales Date whereas another one is the shift date. So there are two joins (Foreign keys) from Sales Table to the Calendar Table.
TABLE_SALES
-SALES_KEY
-SALES_DAY_KEY
-SALES_TIME_KEY
-PRODUCT_KEY
-SHIFT_KEY
-SHIFT_SUPERVISOR_KEY
-SHIFT_CASHIER_KEY
-SHIFT_DAY_KEY
-SALES_QTY
-SALES_AMOUNT
-COST_AMOUNT
I need to develop an analysis on these tables where the Area managers look at the sales by day, month and year and Shift Supervisor and Shift Managers want to look at sales by shifts. (Shift Date).
When I define two joins in OBIEE Administrator, it say that I can have a single join from one dimension. (From Calendar Dimenstion to Sales). this way I can report only by Sales Date.
How can I report by Shift Date?

Create 2 date dimensions: one for calendar date, one for shift date.
Paul

Similar Messages

  • Query between two date columns ?

    Oracle 11g R2
    I'm trying too create a query between two date columns. I have a view that consists of many columns. There are two columns in question called valid_to and valid_from
    Part Number     Valid_from        valid_to
    100                    01/01/2000       01/01/9999
    200                    01/01/2000       01/01/9999
    300                    01/01/2000       01/01/9999
    etc
    If I want to only see rows between with a date range of 01/01/2000 and 01/01/2013 how can I put this as SQL ?
    Thanks in advance

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), 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.
    See the forum FAQ: https://forums.oracle.com/message/9362002
    If you want to find rows that have that exact range, then you can do  something like
    SELECT  *
    FROM    table_x
    WHERE   valid_from  = DATE '2000-01-01
    AND     valid_to    = DATE '2013-01-01'
    If you want to find rows where any or all or the range on the row overlaps any or all of the 200-2013 target range, then
    SELECT  *
    FROM    table_x
    WHERE   valid_from  <= DATE '2013-01-02
    AND     valid_to    >= DATE '2000-01-01'
    If you want rows that are enritely within the target range, it's something else.
    If you want rows that entirely enclose the target range, it's something else again.

  • Creating Time Dimension from date columns in fact tables.

    I remember watching a demo from a BI Tool a couple years ago, wich I swear was OBIEE, and the presentator stated it was possible to create a Time Dimension in the admin tool, based on a date column in other table.
    Can you guys tell me if there's such functionality in OBIEE?
    If so, how could I achieve that?!
    Thanks in advance!
    Marcos

    hi,
    You are trying to make Fact table as Dim table ???
    Fact table has some dim columns??
    We can do this by making a fact table as dim table ,create a dim hierarchy on that table
    Year level :Extract(year from fact_date_column)
    Month and year  level:CAST (Extract(month from fact_date_column) As CHAR(5) ) || CAST (Extract(yearfrom fact_date_column) As CHAR(5) )
    Like this
    But,be careful while doing this make sure that all joins and content levels are good
    As per my knowledge this is not a good way,Experts can add some words lets see!!!!!! :-)
    thanks,
    saichand.v

  • BEx analyzer 7.x: How to determine first data column in result table?

    Hi,
    we are upgrading to 2004s where the SAPBEXqueries Sheet is not used anymore. Instead there is BExRepositorySheet. Is there a way to determine first data column in result table?
    Regards, Josko.

    hi dinesh......
    please use  'INTO TABLE' instead of  ' INTO CORRESPONDING FIELDS OF TABLE '.  and use ' FOR ALL ENTRIES '............based on relavence ....coz when I set break point  over the select queries it took me long time to execute .......
    becoz u didnt used the for all entries  in select query ............ u r read statement
    READ TABLE I_KNA1 INTO WA_KNA1 WITH KEY KUNNR = WA_KNVV-KUNNR.  ..... 
    it is reading wrong kunnr value .............even it took long time to execute ......
    use sort where ever required...
    use for all entries .......and check weather the table initial or not......
    use sy-subrc check where ever reqired ..............

  • Percentage of Total Count of Category in Raw Data Column in Pivot Table

    I have normalized my data in Excel and I have a column: "question 1" and then a column for "gender" which has values as "female" and "male". I have created a pivot table for these two variables, "Gender" and
    "Question 1". My values for Females and Males from the Gender data are presented within my pivot table. I want to present these numbers as percentages of Total "Females" and "Males" that are in the "Gender" column in
    my master dataset. Pivot tables will only allow me to do %'s of data already in the pivot table
    I am attempting to use Calculated Fields within Pivot Tables to resolve this. I do not want to create a separate column in my master data set, but rather, complete all calculations within the pivot table

    Thank you very much, 
    The steps you provided use the total "gender" within the pivot table as the "grand total". 
    If I have a binomial variable, "gender" with "male" as one of the variables, I need the grand total be the total male in the raw data. 
    Example: if there are 100 total males in the raw data for the column "gender"
    and I construct a pivot table with a dependent variable which is a survey question and "gender"  and 30 males "agreed" with the survey question and 20 females "agreed" with the survey question, your instructions for % of grand total would show 60% for
    males who agree [males + females who replied to the survey question],
    when, what I need is the total males in the raw data, 100, used as the total so that the percentage of males who answered "agreed" to the survey question is 30% of all males. 
    Thank you very much

  • Help need with Update statement -Two date columns

    I have two tables rate_change and load ,i want to update the next_rate_change_date and next_rate_change_date columns ,load table has rate_change_effe_term column has value (12) that represents months for each loan,
    i want to take that rate_change_effe_term from load table and add it to min values of rate_chng_effective_date and then update the next_rate_change_date and then continue to do for all the rows of that loan_numer.
    Please see the below sample data.
    Current_data:::
    Loan_number rate_chng_effective_date next_rate_change_date
    111111 02/01/2012 02/01/2014
    111111 03/01/2012 02/01/2014
    111111 06/01/2012 02/01/2014
    111111 07/01/2012 02/01/2014
    111111 08/01/2012 02/01/2014
    Requrired format
    Loan_number rate_chng_effective_date next_rate_change_date
    111111 02/01/2012 02/01/2014
    111111 02/01/2014 02/01/2016
    111111 02/01/2016 02/01/2018
    111111 02/01/2018 02/01/2020
    111111 02/01/2020 02/01/2022
    /* Formatted on 10/24/2012 9:34:23 PM (QP5 v5.227.12220.39724) */
    CREATE TABLE rate_change
       loan_number                NUMBER (10),
       rate_chng_effective_date   VARCHAR2 (20),
       next_rate_change_date      VARCHAR2 (20)
    INSERT INTO rate_change
         VALUES (111111, '02/01/2012', '02/01/2014');
    INSERT INTO rate_change
         VALUES (111111, '03/01/2012', '02/01/2014');
    INSERT INTO rate_change
         VALUES (111111, '06/01/2012', '02/01/2014');
    INSERT INTO rate_change
         VALUES (111111, '07/01/2012', '02/01/2014');
    INSERT INTO rate_change
         VALUES (111111, '08/01/2012', '02/01/2014');
    COMMIT;
    CREATE TABLE Load
       loan_number             NUMBER (10),
       Correct_day             VARCHAR2 (20),
       rate_change_effe_term   VARCHAR2 (20)
    INSERT INTO Load
         VALUES (111111, '02/20/2012', '24');
    INSERT INTO Load
         VALUES (222222, '02/15/2010', '96');
    COMMIT;
    Current_data:::
    Loan_number   rate_chng_effective_date        next_rate_change_date
    111111            02/01/2012                             02/01/2014
    111111            03/01/2012                              02/01/2014
    111111            06/01/2012                             02/01/2014
    111111            07/01/2012                            02/01/2014
    111111            08/01/2012                            02/01/2014
    Requrired format
    Loan_number   rate_chng_effective_date        next_rate_change_date
    111111            02/01/2012                             02/01/2014
    111111            02/01/2014                            02/01/2016
    111111            02/01/2016                             02/01/2018
    111111            02/01/2018                            02/01/2020
    111111            02/01/2020                            02/01/2022
    Any ideas ,suggestion greatly helps . Thank you  very much.

    try with below query.
    update rate_change
    SET rate_chng_effective_date   = To_CHAR(ADD_MONTHS((select MIN(TO_DATE(rate_chng_effective_date,'MM/DD/YYYY'))
                                                          FROM rate_change
                                                          WHERE loan_number = 111111)
                                                          (rownum -1)*(select rate_change_effe_term 
                                                          FROM Load
                                                          WHERE loan_number  =111111) ),'MM/DD/YYYY'  )          
         ,next_rate_change_date      = To_CHAR(ADD_MONTHS((select MIN(TO_DATE(next_rate_change_date,'MM/DD/YYYY'))
                                                          FROM rate_change
                                                          WHERE loan_number = 111111)
                                                          (rownum -1)*(select rate_change_effe_term 
                                                          FROM Load
                                                          WHERE loan_number  =111111) ),'MM/DD/YYYY'  )
    WHERE  loan_number = 111111 ;Thanks,ram

  • Selecting date column from a table

    hi
    I have a problem that looks wierd for me.
    I have a table called blog_post which has a date field called publish_date
    I have done this first.
    alter session set nls_date_format='dd/mm/yyyy';
    then
    SQL> select publish_date from blog_post;
    PUBLISH_DA
    09/07/2007
    02/07/2007
    02/07/2007
    02/07/2007
    09/07/2007
    now the wierd thing is that when i am selectin the same date it is not returning anything
    SQL> select publish_date from blog_post where publish_date='09/07/2007';
    no rows selected
    Thanks for any help.
    Ganesh

    I don't know anything about Hibernate, but the reason why you need to specify the trunc(publish_date) = to_date('09/07/2007','dd/mm/yyyy') is because of the way that Oracle stores date/time internally.
    It's labelled as a date field, but the time is automatically stored as well. So, if you're just wanting to compare the date to another date, you need to ignore the time part of the column - the trunc function does this.
    As for the "to_date(<date>, <date mask>)", well, you want to compare a date to a date, not a string. You could rely on the implicit conversion, governed by the nls settings, but I really, really, really wouldn't. In fact, I can't stress enough how much of a bad idea that would be! It's best to make things explicit.

  • Change Date Column in database table format from mm/dd/yyyy to dd/mm/yyyy

    Hi I use Jdeveloper 11G with an Oracle Database.
    My table is empty currently but I am importing some excel columns into it and the dates in them are throwing errors because you have some dates like 14/09/2012 which would mean the month is out of range even though its not.
    This seems like a simple thing to do but I was unable to find how online.
    Please Help

    I'm not sure I understand COlumn Type is DATE
    There is no Simple Date type. This is DATABASE, has nothing to do with Entities and Views etc. This is straigh in the Database Table.
    Edited by: Dino2dy on Nov 6, 2012 5:47 AM

  • Getting a list of all months between 2 DATE columns for a table

    Current set:
    IF OBJECT_ID('tempdb..#TEST') IS NOT NULL
    DROP TABLE #TEST
    CREATE TABLE #TEST
    ID INT,
    DOB DATE,
    EffectiveDate DATE,
    TerminationDate DATE,
    GCode CHAR(1)
    INSERT INTO #TEST
    VALUES
    (1043,'1/1/1970','1/1/2014','4/1/2014','S'), -- Active in month Jan,Feb,March,April
    (1051,'1/1/1989','3/1/2014','5/1/2014','P'), -- Active in month March,April,May
    (1070,'1/1/2010','5/1/2014','8/1/2014','G') -- Active in month May,June,July,August
    SELECT * FROM #TEST
    Expected result set:
    ID          Month         GCode
    1043      January      S
    1043      February    S
    1043      March         S
    1043      April           S
    1051      March        P
    1051      April          P
    1051      May          P
    ---- Similarly for ID 1070
    This is needed for the reporting and each ID will have points associated to it, that will be a separate column that I'll be adding. The reason that I want this result set is because, the user might say, how many points did the ID have for a particular month.
    The points are not going to change for an ID. Please let me know how to get the expected result set

    Try
    -- code #1
    set LANGUAGE English;
    set dateformat MDY;
    declare @Month table (N int, T varchar(20));
    declare @I int, @D date;
    set @I= 1;
    set @D= '1/1/2014';
    while @I <= 12
    begin
    INSERT into @Month values (@I, DateName(month, @D));
    set @I+= 1;
    set @D= DateAdd(month, +1, @D);
    end;
    SELECT ID, T, GCode
    from @Month as M inner join
    #TEST as T on M.N between Month(EffectiveDate) and Month(TerminationDate)
    order by ID, N;
    José Diz     Belo Horizonte, MG - Brasil

  • How to determine most recent date from the date column of internal table

    Dear friends
    would you like to tell me. how i determine the most recently changed record by looking at date and time from internal table i am not supposed to sort the table by date and time... I must check date and time with other records date and time to determine which record is most recently changed...
    here the scenario is.
    id idnumber chdate chtime
    1 123456 20060606 135312
    2 123456 20060606 135900
    3 123456 20060606 132300
    4 123457 20060606 140000
    5 123457 20060606 142500
    in the above scenario i must keep in my mind that the most recently changed record is identical to its idnumber i can say that:
    the record should be fetched this way
    id idnumber chdate chtime
    3 123456 20060606 132300
    5 123457 20060606 142500
    because here the id 3 is the most recently changed in the idnumber 123456
    where id 5 is the most recently changed in the idnumber 123457
    please help me to determin how i am supposed to carry out this task any suggestion, code will be great help of mine.
    regards
    Naim

    After testing my suggestion above, I realized that it doesn't work because the delete adjacent actually will keep the first one and delete the rest.  I'm working with Srinivas's code a bit now,  I think it is almost what you want.  I am under the impression that you dont' want to HIGHest date/time, but just the last record of the sequence, if this is the case, then this code will help.  Here we will assign an index to each record per the idnumber, that way we can sort it and get the lastest record.
    report zrich_0001.
    types: begin of itab_type,
            id       type i,
            idnumber type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type.
    types: begin of itab_type2,
            id       type i,
            idnumber type i,
            index    type i,
            chdate   like sy-datum,
            chtime   like sy-uzeit.
    types: end of itab_type2.
    data: itab     type table of itab_type with header line,
          itab2    type table of itab_type2 with header line,
          prev_rec type itab_type.
    data: v_id type i.
    start-of-selection.
      itab-id       = 1.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135312'.
      append itab. clear itab.
      itab-id       = 2.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '135900'.
      append itab. clear itab.
      itab-id       = 3.
      itab-idnumber = 123456.
      itab-chdate   = '20060606'.
      itab-chtime   = '142500'.
      append itab. clear itab.
      itab-id       = 4.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '140000'.
      append itab. clear itab.
      itab-id       = 5.
      itab-idnumber = 123457.
      itab-chdate   = '20060606'.
      itab-chtime   = '120000'.
      append itab.
      clear itab.
    <b>  data: counter type i.
    * Assign an index to each row per idnumber
      loop at itab.
        on change of itab-idnumber.
        if sy-tabix > 1.
          clear counter.
          endif.
        endon.
        clear itab2.
        move-corresponding itab to itab2.
        counter = counter + 1.
        itab2-index = counter.
        append itab2.
      endloop.
    * Sort it and get rid of older records.
      sort itab2  by idnumber ascending
                     index descending.
      delete adjacent duplicates from itab2 comparing idnumber.</b>
      read table itab2 with key idnumber = '123456'.
      write:/ itab2-chdate, itab2-chtime.
      read table itab2 with key idnumber = '123457'.
      write:/ itab2-chdate, itab2-chtime.
    Regards,
    Rich Heilman

  • Employee related data columns  from  hrms table

    i am new to HRMS tables.
    i have to create employee report temporary table, columns are given below.
    Gender code
    Gender Description
    Grade code
    Grade Description
    Country name
    Nationality
    from which tables i can find these columns.i need employee tables names where i can find these columns.

    hi,
    there is no table with name per_all_populate_f
    I guess you are referring to per_all_people_f
    for grades the table are per_valid_grades
    for positions hr_all_positions_f,per_position_definitions

  • Difference between two date columns

    Dear professionals,
    how to get different between two columsn (sati_do-sati_od) in format hh24:mi:
    select to_char(sati_od,'hh24:mi') "hh:mi format",
    to_char(sati_do,'hh24:mi') "orginal_value_col2",
    sati_od "original_value_col1",
    sati_do "original value",
    sati_do-sati_od "Difference"
    from accbtp_pliskljucenjaodobrenja
    where idplisklj= 22999;where result is:
    hh:mi format orginal_value_col2 original_value_col1       original value            Difference            
    09:00        15:00              01.12.10                  01.12.10                  0,25                  
    09:00        15:00              01.12.10                  01.12.10                  0,25                  
    09:00        15:00              01.12.10                  01.12.10                  0,25                  
    09:00        15:00              01.12.10                  01.12.10                  0,25                   Thx in advance, Adnan

    Mahanam wrote:
    select trunc( mod( (e-j)*24, 24 ) ) ||':'||trunc( mod( (e-j)*24*60, 60 ) )  "Hr:Mi"
    from (
    select t.*,
    trunc(sysdate,'y')+jd+jh/24+jm/24/60 j,
    trunc(sysdate,'y')+ed+eh/24+em/24/60 e
    from t
    ) t
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:96012348060
    Thx for answering, this works now !
    select to_char(sati_od,'hh24:mi') "hh:mi format",
    to_char(sati_do,'hh24:mi') "orginal_value_col2",
    sati_od "original_value_col1",
    sati_do "original value",
    sati_do-sati_od "Difference",
    trunc( mod( (sati_do-sati_od)*24, 24 ) ) ||':'||trunc( mod( (sati_do-sati_od)*24*60, 60 ) )  "Hr:Mi"
    from accbtp_pliskljucenjaodobrenja
    where idplisklj= 22999;result is
    hh:mi format orginal_value_col2 original_value_col1       original value            Difference             Hr:Mi                                                                            
    09:00        15:00              01.12.10                  01.12.10                  0,25                   6:0                                                                              
    09:00        15:00              01.12.10                  01.12.10                  0,25                   6:0                                                                              
    09:00        15:00              01.12.10                  01.12.10                  0,25                   6:0                                                                              
    09:00        15:00              01.12.10                  01.12.10                  0,25                   6:0                                                                              

  • Date Column not getting sorted in a table in web Dynpro Java

    Hi All,
    I am facing an issue while sorting the date column in a table in my web dynpro java application.
    When the date is displayed in the sql format in tha table, I am able to sort the date column successfully but when we convert the date field from sql format to util format in our table and then sort it does not work.
    Kindly let us know the steps to be followed in this case to sort the date column of a table in Simple Date format as we do not want date in the sql format to be displayed.
    Thanks & Regards,
    Anurag

    Hi,
    You might want to check whether both your browser's language settings are identical. The browser language could also determine the date format.
    As a workaround, you could add an extra attribute to your context, and set the calculated property to 'true'.
    In your table, add a new column and bind to this new attribute, and hide your original date column
    If you sort using the date column that's hidden now, you could use the calculated field to fixed-format your date the way you prefer (by using the SimpleDateFormatter class for instance)
    Cheers,
    Robin

  • What is the best way to dynamically create table partition by year and month based on a date column?

    Hi,
    I have a huge table and it will keep growing. I have a date column in this table and thought of partition the table by year and month. Can any you suggest better approach so that partition will create automatically for new data also along with the existing
    data? Nothing but automatically/dynamically partition should create along with file group and partition files.
    Thanks in advance!
    Palash 

    Also this one
    http://weblogs.sqlteam.com/dang/archive/2008/08/30/Sliding-Window-Table-Partitioning.aspx
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Hash Marks Displayed In Date columns

    Hi Experts
    I have two date columns in my report.
    But when i export this to excel spreadsheet i am getting
    Hash Marks Displayed Instead of Dates on few of cells ....
    I am really frustrated and tried everything by formatting date using to_char ,to_date in universe and also tried formatting
    date in Infoview side.
    But whenever i export this , I get ######## instead of dates .
    Can anyone please advise ?

    Hi Savrav,
    1. Fields in excel give ####### values when the column width is not sufficient to show the complete length of values in the cells.
    I hope you've tried expanding the column width in excel.
    2. Also, what is the source file? Is it a DB table or a BEx query on which you have built the Universe?
    Worth checking the format of the date field in the source file.
    Regards,
    Srilakshmi B

Maybe you are looking for

  • Tax Number Validation in BP transaction

    Hi experts, I'm working on a validation in Tax Number 1 field in transaction code BP when creating Business Partner. I have read that you have to create a custom FM and make your validations there and use FM 'BUS_MESSAGE_STORE' to raise an error mess

  • Creating an RDI  file from SAP script

    Hello All, I would like to create an RDI file from SAP Script. Please can anyone let me know how do we do it programmatically. I am aware of the option of setting RDI parameter to 'X'. However my requirement is to allow user to have a print preview o

  • Link b/w rseg and vbrk

    hai gurus, how can i link vbrk and rseg and rbkp tables and i required to get the matnr of freight forwarder invoice. with thanks

  • Using BW BAPI's in VC

    Hello, We have an EP connected to our BI 7 backend system and are currently using it for displaying BW reports and dashboards in VC . It is using logon tickets for user authentication in BW. Now we need to use certain Bapi's in BI in VC which can be

  • How to update aperture 3.0.2 under os x mavericks

    i bought aperture 3.0.2 a few years ago. How can i install and updat this programm from the CD using mavericks? I