Date Query for SimpleDateFormat

HI,
I’m trying to create a Toplink query for Date. Toplink always generates the date query in the following format for my Oracle DB:
1.     If I pass the value new Date() in then it generates
to_date('2005-01-05 30368','yyyy-mm-dd sssss')
2.     If I use SimpleDateFormat with the format “yyyy/mm/dd" it creates
to_date('2007-07-05 0','yyyy-mm-dd sssss')
What is the value that comes after the day (30368 and 0) in each query?
How can I make the Toplink to generate date without the time component? Preferably if there is a way for toplink to generate the date based on the Java SimpleDateFormat that would be good.
Thanks
-Mani

The DATE type in Oracle stores both a date and time. The 0/30368 is the time in seconds sssss, 0 means no time. You should not have any issue with this format, what are you trying to do?

Similar Messages

  • How to Create Filter by date Query for access using Data base connectivity tool

    Hello,
    I had started my project by reading Access datas, by using an UDL connection,
    but now i want to create an access filter using a query that would permit to select two dates, and to obtain all corresponding datas, how to do it using the Parmetrized SQL query?
    Best regards,
    Remark: i dont know the SQL language
    ~~~~~~~~~~~~~~~~~~Looking for a LABVIEW JOB (In EUROPE)>~~~~~~~~~~~~~~~~~~
    **The Best Way To Predict**The**Future Is To Invent It**
    Solved!
    Go to Solution.

    Hi mike,
    I want to thank you for your help, i really appreciate it,
    i tried to make the code as ur picture, i had no problem to execute it, but i have no data's in the output
    i changed the date format, because i suppose that its a short date format in the database.
    can you just look at it, and tell me if you can find the problem,
    thank you again for your help
    Best regards,
    ~~~~~~~~~~~~~~~~~~Looking for a LABVIEW JOB (In EUROPE)>~~~~~~~~~~~~~~~~~~
    **The Best Way To Predict**The**Future Is To Invent It**
    Attachments:
    db.JPG ‏126 KB
    lav.JPG ‏82 KB

  • Need MDX query to find something like date diff and Date Range for last 10 days

    Hi ,
    I need two Query .First Query for below;
    I have below data in table like.
    Cat      StartDate    EndDate     
    A    2000-01-01     2000-01-15   
    B    2000-01-02     2000-01-30    
    C    2000-01-01     2000-01-31    
    D    2000-02-01     2000-02-28    
    A    2000-01-10     2000-01-31    
    I need if Startdate and Date completes whole one month then set status =1 else  0 using MDX query.
    like this ;
    Cat      StartDate    EndDate       Status
    A    2000-01-01     2000-01-15    1
    B    2000-01-02     2000-01-30    0
    C    2000-01-01     2000-01-31    1
    D    2000-02-01     2000-02-28    1
    A    2000-01-10     2000-01-31    1
    In second query I need last 10 days from current days like;
    Now = 8/20/2014
    output will be ;
    8/20/2014
    8/19/2014
    8/18/2014
    8/17/2014
    8/16/2014
    8/15/2014
    8/14/2014
    8/13/2014
    8/12/2014
    8/11/2014
    8/10/2014
    Please help me .
    Thanks

    Hi Prajapati,
    In your scenario, you can use Properties and Datediff function to achieve your requirement. Since not know the structure of your cube, we cannot give you the esact query.
     I have tested it on the AdventureWorks cube, the query below is for you reference.
    WITH MEMBER [Measures].[StartDate]
    AS
    [Employee].[Employee Department].CURRENTMEMBER.PROPERTIES('Start Date')
    MEMBER [Measures].[WorkYear]
    AS
    DATEDIFF('yyyy',[Measures].[StartDate],NOW())
    MEMBER [Measures].[Status]
    AS
    IIF(DATEDIFF('yyyy',[Measures].[StartDate],NOW())>10,1,0)
    SELECT {[Measures].[StartDate],[Measures].[WorkYear],[Measures].[Status]} ON 0,
    [Employee].[Employee Department].[Employee].MEMBERS ON 1
    FROM [Adventure Works]
    Results
    Reference
    http://msdn.microsoft.com/en-us/library/ms144821.aspx
    Regards,
    Charlie Liao
    TechNet Community Support

  • How can I do for a row of a query be data provider for a variable?

    Hi friends, I have a problem !
    How can I do for a row of a query be data provider for a variable?
    I need that a value of variable be stored when the user select a row in a query. At the BPS we can do this configuring the variable selector in WIB, and in a WAB how I can do this ?
    Best regards,
    Gustavo Liberado

    In this case when I press the key to call other forms I need to wait for the response in the secondary form and then process the result.That is exactly what a "modal JDialog" (or JOptionPane) are used for.
    Try it. Create a short demo program. All you need is a JFrame with a single button to show the modal dialog. All you modal dialog needs is a single button to close the dialog. After you show the modal dialog add a System.out.println(...) statement in your code and you will see that it is not executed until the dialog is closed.
    Then once you understand the basics you add the code to your real program.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.
    Don't forget to use the Code Formatting Tags so the posted code retains its original formatting. That is done by selecting the code and then clicking on the "Code" button above the question input area.

  • Query for file version less than 10.0 does not return expected data

    I'm trying to build a query for all PCs that have a version of Iexplore.exe in c:\windows\program files\ that is less than 10.0 .  When I run the query it returns no data. When I change 10.0 in the query to 9.9 it returns files with version 10.xxx in
    the results.  Its as if it is seeing 10.0 as 1.0.   Is this expected ?
    select SMS_R_System.Name, SMS_R_System.ADSiteName, SMS_G_System_SoftwareFile.FileName, SMS_G_System_SoftwareFile.FileVersion from  SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where
    SMS_G_System_SoftwareFile.FileName = "iexplore.exe" and SMS_G_System_SoftwareFile.FilePath = "C:\\program files\\internet explorer\\" and SMS_G_System_SoftwareFile.FileVersion < "9.9"

    It is because the values are not integer, they are a string. And therefore 1 is smaller then 9.
    http://www.enhansoft.com/

  • Query for finding data during special holidays

    Hi, i have a table for special holidays that looks like this:
    PROFILE_DAY
    VAR_DATE
    REGULAR_HOLIDAY
    1/1/2013
    H_WEEK_THURSDAY
    3/28/2013
    H_WEEK_FRIDAY
    3/29/2013
    REGULAR_HOLIDAY
    12/24/2013
    REGULAR_HOLIDAY
    12/25/2013
    REGULAR_HOLIDAY
    12/31/2013
    And another table (LOAD_PROFILE_TEST), which contains LOAD_PROF1 values from (TIME_EQ) 0 to 24 at intervals 0.25 for (PROFILE_DAY) MONDAY to SUNDAY including REGULAR_HOLIDAY, H_WEEK_THURSDAY and H_WEEK_FRIDAY.  All in all, this table contains 970 records (97 records between 0 to 24 with interval of 0.25 per PROFILE_DAY, with 10 distinct PROFILE_DAY).
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    REGULAR_HOLIDAY
    11.47
    0.25
    REGULAR_HOLIDAY
    11.27
    0.5
    REGULAR_HOLIDAY
    11.3
    0.75
    REGULAR_HOLIDAY
    11.08
    0
    MONDAY
    11.27
    0.25
    MONDAY
    11.33
    0.5
    MONDAY
    11.18
    Now, I have this query to update value of LOAD_PROF2 of the said table whenever parameters V_DATE_OUT & V_DATE_IN is entered:
    UPDATE LOAD_PROFILE_TEST
         SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
         WHERE  UPPER(PROFILE_DAY) IN (select UPPER(to_char(:V_DATE_OUT + (level-1), 'fmDAY'))
                       from  dual
                       connect by level <=  :V_DATE_IN - :V_DATE_OUT  + 1
    where :LOAD_DIFF is a certain pre-determined value.
    This query works fine if i am trying to update regular days from MONDAY to SUNDAY.  What i would like to do is to determine if the two parameter dates, V_DATE_OUT & V_DATE_IN would fall under any of the holidays on the first table LOAD_PROFILE_TEST, then update only those rows.  For example, V_DATE_OUT = 12/02/2013, Monday and V_DATE_IN = 12/06/2013, Friday.  The query above would update the values of LOAD_PROF2 for PROFILE_DAY -  MONDAY to FRIDAY, corresponding to dates 12/02/2013 and 12/06/2013.  If however, V_DATE_OUT = 12/23/2013, Monday and V_DATE_IN = 12/27/2013, Friday, this should update the rows corresponding to PROFILE_DAY - MONDAY for 12/23/2013, THURSDAY for 12/26/2013, FRIDAY for 12/27/2013, and REGULAR_HOLIDAY for the dates 12/24/2013 and 12/25/2013 since these two are included in the first table (table of holidays).  This same scenario will work the same way when V_DATE_OUT  and/or V_DATE_IN fall in the dates 3/28/2013 and 3/29/2013.  All other dates not included in the table for special holidays will be treated according to the day they fall on (Monday thru Sunday).  I hope my point is clear.  Thank you in advance.

    Thanks for your reply.  Firstly, I am using Forms [32 Bit] Version 10.1.2.0.2 (Production).  I will try to explain a little further but I don't know if i can give the exact details of the tables since this would be voluminous. First i have a table REG_HOLIDAYS, whcih contain the following:
    PROFILE_DAY
    VAR_DATE
    REGULAR_HOLIDAY
    1/1/2013
    H_WEEK_THURSDAY
    3/28/2013
    H_WEEK_FRIDAY
    3/29/2013
    REGULAR_HOLIDAY
    12/24/2013
    REGULAR_HOLIDAY
    12/31/2013
    REGULAR_HOLIDAY
    12/25/2013
    Now i have another table LOAD_PROFILE_TEST which i will simplify just to show what i wanted to do:
    CREATE
    TABLE LOAD_PROFILE_TEST
    TIME_EQ
    NUMBER (5, 2),
    PROFILE_DAY
    VARCHAR2 (15 BYTE),
    LOAD_PROF1
    NUMBER (6, 2), 
    LOAD_PROF2
    NUMBER (6, 2)
    Here are the sample values of this table:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    0
    Tuesday
    2.1
    0
    Wednesday
    2.3
    0
    Thursday
    2.5
    0
    Friday
    2.2
    0
    Saturday
    2.4
    0
    Sunday
    2.3
    0
    Regular_holiday
    1.9
    0.25
    Monday
    2.1
    0.25
    Tuesday
    2.1
    0.25
    Wednesday
    2.4
    0.25
    Thursday
    2.2
    0.25
    Friday
    2.5
    0.25
    Saturday
    2.3
    0.25
    Sunday
    2.3
    0.25
    Regular_holiday
    2.5
    However, in the actual table, TIME_EQ will start with 0 until 24 with interval of 0.25 (i.e 0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, ...23.5, 23.75, 24).  So for a PROFILE_DAY of 'Monday', there will be 97 rows corresponding to TIME_EQ of 0 to 24.  The same is true for Tuesday, Wednesday until Sunday including Regular_holiday.  All in all, this table would contain 776 rows.  LOAD_PROF1 values are random values initally inputted with PROFILE_DAY and TIME_EQ.
    The first goal is to UPDATE this table (LOAD_PROFILE_TEST) by updating the column LOAD_PROF2 by adding a certain parameter value, :LOAD_DIFF, say 0.1. Now, i will have two scenarios to show what i would like to happen.  First, i have two date parameters :V_DATE_OUT and :V_DATE_IN.
    First Case, V_DATE_OUT = 12/15/2013 (Monday); V_DATE_IN = 12/22/2013 (Sunday)
    I will have this query to update said table:
    UPDATE LOAD_PROFILE_TEST
           SET LOAD_PROF2 = LOAD_PROF1 + :LOAD_DIFF
       WHERE   UPPER(PROFILE_DAY) IN (select UPPER(
                                                                     to_char(
                                                                          :V_DATE_OUT + (level-1),
                                                                          'fmDAY'))
                                                                    from  dual
                                                     connect by level <=
                                                           :V_DATE_IN - :V_DATE_OUT  + 1);
    The output of this query would be:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    2.1
    0
    Tuesday
    2.1
    2.2
    0
    Wednesday
    2.3
    2.4
    0
    Thursday
    2.5
    2.6
    0
    Friday
    2.2
    2.3
    0
    Saturday
    2.4
    2.5
    0
    Sunday
    2.3
    2.4
    0
    Regular_holiday
    1.9
    0.25
    Monday
    2.1
    2.2
    0.25
    Tuesday
    2.1
    2.2
    0.25
    Wednesday
    2.4
    2.5
    0.25
    Thursday
    2.2
    2.3
    0.25
    Friday
    2.5
    2.6
    0.25
    Saturday
    2.3
    2.4
    0.25
    Sunday
    2.3
    2.4
    0.25
    Regular_holiday
    2.5
    Since, 12/15/2013 up to 12/22/2013 is from Monday to Sunday without having a particular day included in the first table, REG_HOLIDAYS, therefore all the rows with Monday to Sunday are updated.
    Second Case, V_DATE_OUT = 12/23/2013 (Monday); V_DATE_IN = 12/29/2013 (Sunday)
    Take note that 12/24 and 12/25 are included in the first table, REG_HOLIDAYS, therefore i need a query so that this would be my output afterwards:
    TIME_EQ
    PROFILE_DAY
    LOAD_PROF1
    LOAD_PROF2
    0
    Monday
    2
    2.1
    0
    Tuesday
    2.1
    0
    Wednesday
    2.3
    0
    Thursday
    2.5
    2.6
    0
    Friday
    2.2
    2.3
    0
    Saturday
    2.4
    2.5
    0
    Sunday
    2.3
    2.4
    0
    Regular_holiday
    1.9
    2.0
    0.25
    Monday
    2.1
    2.2
    0.25
    Tuesday
    2.1
    0.25
    Wednesday
    2.4
    0.25
    Thursday
    2.2
    2.3
    0.25
    Friday
    2.5
    2.6
    0.25
    Saturday
    2.3
    2.4
    0.25
    Sunday
    2.3
    2.4
    0.25
    Regular_holiday
    2.5
    2.6
    As can be seen, since 12/23/2013 up to 12/29/2013 is from Monday to Sunday, rows with Monday upto Sunday should be updated, HOWEVER, since 12/24 and 12/25 which falls on a Tuesday and a Wednesday also were declared as holidays (included in the REG_HOLIDAYS table),  instead of updating rows with PROFILE_DAY of Tuesday and Wednesday, the query should instead update rows with Regular_holiday as PROFILE_DAY and leave as is the rows with Tuesday and Wednesday.  Additional note, days declared in the REG_HOLIDAYS table with PROFILE_DAY of Regular_holidays are treated as DISTINCT as in the case of 12/24 and 12/25.
    The query you gave me gives the correct value if the involved days between V_DATE_OUT and V_DATE_IN is from Monday to Sunday only, otherwise it always gives Regular_holiday only regardless of the other dates queried.  As in the first case above, it would give Monday to Sunday (correct) but for the second case, it will only give Regular_holiday, the other days (Monday, Thursday, Friday, Saturday and Sunday) was not outputted.
    I hope this became clearer since i will still be needing this for another query which i will inquire again after resolving this issue.  Thanks a lot for your help.

  • All Dates displayed for "Characteristic Values" in Query Designer

    Hello Experts,
    We are on BI 7.0, level 13.  I am having an issue within the Query Designer with regards to dates.  I have a write-optimized DSO that contains 3 date fields (for example, ZDATE1, ZDATE2, and ZDATE3).  Each date InfoObject is of type DATS so the system automatically creates it with reference to 0DATE. 
    When I create a query in the Query Designer, on the left hand side, I expand the "Characteristic Values" node under each date field.  The Query Designer shows the same list of values for each of the 3 dates even though they are not valid values posted in the DSO for those fields.
    For example, ZDATE1 only has 1 value posted in the DSO (01/01/2005).
    ZDATE2 only has 1 value posted in the DSO (01/01/2006).
    ZDATE3 only has 1 value posted in the DSO (01/01/2007).
    Bute when I expand the "Characteristic Values" node in the Query Designer, I see ALL THREE values under each date field.  I would expect to only see the 1 value posted for the InfoObject in the DSO.  Also note that each InfoObject is defined to show "Only posted values in InfoProvider".
    It appears that Query Designer will show all values for the reference InfoObject 0DATE instead of the ones posted to the actual InfoObject in the DSO.  If I delete the data in the DSO, the Characteristic Values list still remains because they exist in 0DATE.  Anyone encounter this before?  How can I get the Characteristic Values list to only show posted values for that InfObject?
    Thanks for your help!
    J

    Thanks for the response.  I went into the DSO and right clicked on each of the Date fields.  I looked at the Provider-specific properties and there is the option for "Query Exec.FilterVal" which only restricts what values appear when restricting during execution, not during query creation.
    Is there someplace else I should look or someplace else I can make change to only display posted dates when creating a query?  Thanks!

  • Query regarding the data type for fetcing records from multiple ODS tables

    hey guys;
    i have a query regarding the data type for fetcing records from multiple ODS tables.
    if i have 2 table with a same column name then in the datatype under parent row node i cant add 2 nodes with the same name.
    can any one help with some suggestion.

    Hi Mudit,
    One option would be to go as mentioned by Padamja , prefxing the table name to the column name or another would be to use the AS keyoword in your SQL statement.
    AS is used to rename the column name when data is being selected from your DB.
    So, the query  Select ename as empname from emptable will return the data with column name as empname.
    Regards,
    Bhavesh

  • Query for data

    Hi all, i am trying to write a query for a specific scenario using analytic functions.
    i have a table that has data in week basis. here is some sample data
    id date value
    1 1/4/10 A
    1 1/11/10 B
    1 1/18/10 C
    2 ....
    2 ....
    each date represent the beginning of the week. i have another table that contains calendar dates that include day of the week excluding weekends and holidays.
    example data
    id date
    1 1/4/10
    1 1/5/10
    1 1/6/10
    1 1/7/10
    1 1/8/10
    1 1/11/10
    1 ...... SO ON
    as you can see 1/1/10, 1/2, 1/3 are not present because they are either holidays or weekends.
    what i want to do is join this two tables by id and the output should be the following
    1 1/4/10 A
    1 1/5/10 A
    1 1/6/10 A
    1 1/7/10 A
    1 1/8/10 A
    1 1/11/10 B
    1 1/12/10 B
    1 1/13/10 B
    1 1/14/10 B
    1 1/15/10 B
    and so on. so as you can see. i am converting the week table (first table) into day basis. i tried to use analytic function but i was not very successful since i am new to them. any help will be appricatiate. provide sample query if possible. thanks a lot

    Hi,
    What if the week crosses over 2 months.
    Fo example March the last week starts on 29 and has 1st apr and 2nd apr in the same week.Would you consider those?
    If not here is one way of doing it.
    with t1 as (
                select 1 id,DATE '2010-03-01' dt,'A' val from dual union all
                select 1,DATE '2010-03-08','B' from dual union all
                select 1,DATE '2010-03-15','C' from dual UNION ALL
                select 1,DATE '2010-03-22','D' from dual    UNION ALL
                select 1,DATE '2010-03-29','E' from dual  
         t2 as (
                select 1 id,DATE '2010-03-01' dt from dual union all
                select 1,DATE '2010-03-02' from dual union all
                select 1,DATE '2010-03-03' from dual union all
                select 1,DATE '2010-03-04' from dual union all
                select 1,DATE '2010-03-05' from dual union all
                select 1,DATE '2010-03-08' from dual union all
                select 1,DATE '2010-03-09' from dual union all
                select 1,DATE '2010-03-10' from dual union all
                select 1,DATE '2010-03-11' from dual union all
                select 1,DATE '2010-03-12' from dual UNION ALL
                select 1,DATE '2010-03-15' from dual UNION ALL
                select 1,DATE '2010-03-16' from dual UNION ALL           
                select 1,DATE '2010-03-17' from dual UNION ALL
                select 1,DATE '2010-03-18' from dual UNION ALL
                select 1,DATE '2010-03-19' from dual UNION ALL
                select 1,DATE '2010-03-22' from dual UNION ALL
                select 1,DATE '2010-03-23' from dual UNION ALL                                               
                select 1,DATE '2010-03-24' from dual UNION ALL                                                           
                select 1,DATE '2010-03-25' from dual UNION ALL                                                           
                select 1,DATE '2010-03-26' from dual UNION ALL                                                         
                select 1,DATE '2010-03-29' from dual UNION ALL
                select 1,DATE '2010-03-30' from dual UNION ALL
                select 1,DATE '2010-03-31' from dual UNION ALL
                select 1,DATE '2010-04-01' from dual UNION ALL  
                select 1,DATE '2010-04-01' from dual                                )
               SELECT DISTINCT a.ID,b.dt,a.val,to_char(b.dt,'IW') FROM t1 a,t2 b WHERE a.ID=b.ID
               AND to_char(a.dt,'MON')=to_char(b.dt,'MON')
               AND to_char(a.dt,'IW')=to_char(b.dt,'IW')
               ORDER BY val,dtCheers!!!
    Bhushan

  • Trouble writing Query for Pivoting data from a table

    I am having a little trouble writing a query for converting the below table data into a pivot data. I am trying to write a query for which if I give a single valid report_week date as input it should give me the data for that week and also provide two extra columns, one which gives the data of last week for the same countries and the second column which gives the difference of numbers in both the columns(i.e. COUNT - COUNT_LAST_WEEK).
    REPORT_WEEK     DIVISION     COUNT
    9/26/2009     country1     81
    9/26/2009     country2     97
    9/26/2009     country3     12
    9/26/2009     country4     26
    9/26/2009     country5     101
    10/3/2009     country1     85
    10/3/2009     country2     98
    10/3/2009     country3     10
    10/3/2009     country4     24
    10/3/2009     country5     101
    10/10/2009     country1     84
    10/10/2009     country2     98
    10/10/2009     country3     10
    10/10/2009     country4     25
    10/10/2009     country5     102
    For example, if I give input as 10/10/2009, the output should be as give below.
    REPORT_WEEK     DIVISION     COUNT     COUNT_LAST_WEEK     DIFFERENCE
    10/10/2009     country1     84     85     -1
    10/10/2009     country2     98     98     0
    10/10/2009     country3     10     10     0
    10/10/2009     country4     25     24     1
    10/10/2009     country5     102     101     1
    For example, if I give input as 10/3/2009, the output should be as give below.
    REPORT_WEEK     DIVISION     COUNT     COUNT_LAST_WEEK     DIFFERENCE
    10/3/2009     country1     85     81     4
    10/3/2009     country2     98     97     1
    10/3/2009     country3     10     12     -2
    10/3/2009     country4     24     26     -2
    10/3/2009     country5     101     101     0
    Can anyone please shed some light on Query building for the above scenarios.
    Thank you
    SKP
    Edited by: user11343284 on Oct 10, 2009 7:53 AM
    Edited by: user11343284 on Oct 10, 2009 8:28 AM

    I assume there is no gap in report weeks. If so:
    SQL> variable report_week varchar2(10)
    SQL> exec :report_week := '10/10/2009'
    PL/SQL procedure successfully completed.
    with t as (
               select to_date('9/26/2009','mm/dd/yyyy') report_week,'country1' division,81 cnt from dual union all
               select to_date('9/26/2009','mm/dd/yyyy'),'country2',97 from dual union all
               select to_date('9/26/2009','mm/dd/yyyy'),'country3',12 from dual union all
               select to_date('9/26/2009','mm/dd/yyyy'),'country4',26 from dual union all
               select to_date('9/26/2009','mm/dd/yyyy'),'country5',101 from dual union all
               select to_date('10/3/2009','mm/dd/yyyy'),'country1',85 from dual union all
               select to_date('10/3/2009','mm/dd/yyyy'),'country2',98 from dual union all
               select to_date('10/3/2009','mm/dd/yyyy'),'country3',10 from dual union all
               select to_date('10/3/2009','mm/dd/yyyy'),'country4',24 from dual union all
               select to_date('10/3/2009','mm/dd/yyyy'),'country5',101 from dual union all
               select to_date('10/10/2009','mm/dd/yyyy'),'country1',84 from dual union all
               select to_date('10/10/2009','mm/dd/yyyy'),'country2',98 from dual union all
               select to_date('10/10/2009','mm/dd/yyyy'),'country3',10 from dual union all
               select to_date('10/10/2009','mm/dd/yyyy'),'country4',25 from dual union all
               select to_date('10/10/2009','mm/dd/yyyy'),'country5',102 from dual
    select  max(report_week) report_week,
            division,
            max(cnt) keep(dense_rank last order by report_week) cnt_this_week,
            max(cnt) keep(dense_rank first order by report_week) cnt_last_week,
            max(cnt) keep(dense_rank last order by report_week) - max(cnt) keep(dense_rank first order by report_week) difference
      from  t
      where report_week in (to_date(:report_week,'mm/dd/yyyy'),to_date(:report_week,'mm/dd/yyyy') - 7)
      group by division
      order by division
    REPORT_WE DIVISION CNT_THIS_WEEK CNT_LAST_WEEK DIFFERENCE
    10-OCT-09 country1            84            85         -1
    10-OCT-09 country2            98            98          0
    10-OCT-09 country3            10            10          0
    10-OCT-09 country4            25            24          1
    10-OCT-09 country5           102           101          1
    SQL> exec :report_week := '10/3/2009'
    PL/SQL procedure successfully completed.
    SQL> /
    REPORT_WE DIVISION CNT_THIS_WEEK CNT_LAST_WEEK DIFFERENCE
    03-OCT-09 country1            85            81          4
    03-OCT-09 country2            98            97          1
    03-OCT-09 country3            10            12         -2
    03-OCT-09 country4            24            26         -2
    03-OCT-09 country5           101           101          0
    SQL> SY.

  • Date Picker Result Used in Query for Flash Chart

    Hello,
    I'm creating a flash chart using an SQL Query. The query uses two date pickers for the beginning and ending date of the data the query returns. For some reason the substitution string for the data pickers do not work and do not return any data. If I hard wire the start and end date to something like '12/01/2008' and '01/31/2009' the query and the flash chart work just fine. When use the string representing the data pickers (:P65_BEGIN_DATE and :P65_END_DATE) the query does not return any data. Is there some problem using substitution strings in queries for flash charts??
    For what it's worth here is the query. (Look near the bottom to see where I reference the data pickers):
    SELECT 'Link',
    to_char(Day, 'Mon DD'),
    ((Count("Item Number")-Sum("Devaition"))/Count("Item Number"))*100 as "Precentage"
    from
    (SELECT
    to_date(concat(substr(F4140.PICSDJ, 1, length(F4140.PICSDJ)-3)+1900,
    substr(F4140.PICSDJ, length(F4140.PICSDJ)-2,3)), 'yyyyddd') as Day,
    F4141.PJLITM AS "Item Number",
    sum(F4141.PJTQOH) AS "Sum Qty On Hand",
    sum(F4141.PJTQCT) AS "Sum Qty Counted",
    (decode(sum(F4141.PJTQOH)-sum(F4141.PJTQCT), 0, 0, 1)) as "Devaition"
    FROM F4140 INNER JOIN F4141 ON F4140.PICYNO = F4141.PJCYNO
    WHERE (((F4140.PICYCS) In ('40','50')) AND ((F4141.PJCCCD)='1'))
    GROUP BY to_date(concat(substr(F4140.PICSDJ, 1, length(F4140.PICSDJ)-3)+1900,
    substr(F4140.PICSDJ, length(F4140.PICSDJ)-2,3)), 'yyyyddd'), F4141.PJLITM
    HAVING to_date(concat(substr(F4140.PICSDJ, 1, length(F4140.PICSDJ)-3)+1900,
    substr(F4140.PICSDJ, length(F4140.PICSDJ)-2,3)), 'yyyyddd')
    between to_date(:P65_BEGIN_DATE, 'DD-Mon-YYYY') and to_date(:P65_END_DATE, 'DD-Mon-YYYY') )
    group by Day

    I look at the debug output without changing anything and I am not really sure where the two date pickers are being populated. However I do have defaults set up for each datepicker of:
    P65_BEGIN_DATE: to_char(sysdate - 30, 'DD-MON-YYYY')
    P65_END_DATE: to_char(sysdate, 'DD-MON-YYYY')
    and the dates I would expect show up in the date picker.
    Also I created a Computation of Before Header type with the following PL/SQL expression:
    to_char(sysdate-180, 'DD-MON-YYYY')
    and I see the following output when in debug mode:
    0.05: Computation point: BEFORE_HEADER
    0.05: ...Perform computation of item: P65_BEGIN_DATE, type=PLSQL_EXPRESSION
    0.05: ...Session State: Save "P65_BEGIN_DATE" - saving same value: "03-AUG-2008"
    0.05: Processing point: BEFORE_HEADER
    So I think the datapickers are being populated but the flash chart is still not working.

  • Two or more productid will be accquired by same customerid, by same shipvia, on the same day of the week of shipped date. i want the simple query for this.

    consider this situation,
     Two or more productid will be accquired by same customerid, by same shipvia, on the same  day of the week of shipped date. i want the simple query for this.
    my tables are  from northwind:
    [orders] = OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry.
    [orders details] = OrderID, ProductID, UnitPrice, Quantity, Discount.
    i tried some but it is not exact, it gives wrong result.
    select pd.CustomerID,pd.ProductID, pd.no_of_time_purchased, sd.ShipVia, sd.same_ship_count, shipped_day from
    select ProductID,o.CustomerID,COUNT(productid) as no_of_time_purchased
    from orders o join [Order Details] od on o.OrderID=od.OrderID group by ProductID,o.CustomerID
    having count(od.ProductID) >1) pd
    join
    (select OrderID,customerid, shipvia, count(shipvia)as same_ship_count, DATENAME(DW,ShippedDate)as shipped_day from orders
    group by customerid, ShipVia, ShippedDate having COUNT(ShipVia) > 1 ) sd
    on sd.CustomerID=pd.CustomerID

    Hi,
    I think I have a solution that will at least give you a clue how to go about it. I have simplified the tables you mentioned and created them as temporary tables on my side, with some fake data to test with. I have incldued the generation of these temporary
    tables for your review.
    In my example I have included:
    1. A customer which has purchased the same product on the same day, using the same ship 3 times,
    2. Another example the same as the first but the third purchase was on a different day
    3. Another example the same as the first but the third purchase was a different product
    4. Another example the same as the first but the third purchase was using a different "ShipVia".
    You should be able to see that by grouping on all of the columns that you wich to return, you should not need to perform any subselects.
    Please let me know if I have missed any requirements.
    Hope this helps:
    CREATE TABLE #ORDERS
     OrderID INT,
     CustomerID INT,
     OrderDate DATETIME,
     ShipVia VARCHAR(5)
    CREATE TABLE #ORDERS_DETAILS
     OrderID INT,
     ProductID INT,
    INSERT INTO #ORDERS
    VALUES
    (1, 1, GETDATE(), 'ABC'),
    (2, 1, GETDATE(), 'ABC'),
    (3, 1, GETDATE(), 'ABC'),
    (4, 2, GETDATE() - 4, 'DEF'),
    (5, 2, GETDATE() - 4, 'DEF'),
    (6, 2, GETDATE() - 5, 'DEF'),
    (7, 3, GETDATE() - 10, 'GHI'),
    (8, 3, GETDATE() - 10, 'GHI'),
    (9, 3, GETDATE() - 10, 'GHI'),
    (10, 4, GETDATE() - 10, 'JKL'),
    (11, 4, GETDATE() - 10, 'JKL'),
    (12, 4, GETDATE() - 10, 'MNO')
    INSERT INTO #ORDERS_DETAILS
    VALUES
    (1, 1),
    (2, 1),
    (3, 1),
    (4, 2),
    (5, 2),
    (6, 2),
    (7, 3),
    (8, 3),
    (9, 4),
    (10, 5),
    (11, 5),
    (12, 5)
    SELECT * FROM #ORDERS
    SELECT * FROM #ORDERS_DETAILS
    SELECT
     O.CustomerID,
     OD.ProductID,
     O.ShipVia,
     COUNT(O.ShipVia),
     DATENAME(DW, O.OrderDate) AS [Shipped Day]
    FROM #ORDERS O
    JOIN #ORDERS_DETAILS OD ON O.orderID = OD.OrderID
    GROUP BY OD.ProductID, O.CustomerID, O.ShipVia, DATENAME(DW, O.OrderDate) HAVING COUNT(OD.ProductID) > 1
    DROP TABLE #ORDERS
    DROP TABLE #ORDERS_DETAILS

  • Crosstab Query for Remaining Revenue (Count, If, Date Between )

    Hi all, hope you had a great new year.
    I am wanting to create a crosstab query for my Projects which shows ProjectID in the row headers and Time Periods split into months quarter or year as the Column Headers using the [DateAgreed] from the Session table. 
    I have created crosstabs which show revenue from sessions and count of sessions with different time periods but i am trying to make it so that it counts only completed sessions from before the column date, so that i can then multiply by the [SessionCost].
    Any ideas guys?
    Here's what i have been working with;
    TRANSFORM Sum(([tblSession]![SessionCompleted]*[tblProject]![SessionCost])) AS Revenue
    SELECT tblProject.ProjectID, tblCompany.CompanyName
    FROM (tblSession INNER JOIN tblCompany ON tblSession.CompanyID = tblCompany.CompanyID) INNER JOIN ((tblProject INNER JOIN tblProjectMetrics ON tblProject.ProjectID = tblProjectMetrics.ProjectID) INNER JOIN qryProjectStatus ON tblProject.ProjectID = qryProjectStatus.ProjectID)
    ON (tblProject.ProjectID = tblSession.ProjectID) AND (tblCompany.CompanyID = tblProject.CompanyID)
    GROUP BY tblProject.ProjectID, tblCompany.CompanyName, tblProject.Total
    PIVOT Format([DateAgreed],"yyyy-mm");
    Thanks :)

    Hi Gord0oo,
    You could concatenates the data as a result and show in a cell.
    TRANSFORM Sum([tblProject]![SessionCost])) & ";" & Sum([tblSession]![SessionCompleted]) AS Revenue
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Restriction data entry for input ready query

    Dear All,
    I have an input ready query with two structures for rows and columns.
    However, I have set one of columns' structure's member as "data can be changed with planning functions", i'm able to enter data for that column. When i execute save function, entered valus are being disapperaed.(not benig written to the cube)
    But i want to restrict data entrance for that column. (Like display functionality in BPS)
    I know i can protect fields with excel functionality, but we are using web environment.
    How can i resolve mentioned issue?
    Thanks
    Alkan

    Hi Bindu,
    Thanks for your quich answer.
    In web environment, i think i need to use WEB API.
    Do i need to write java script? Or is there any particular class to manage the properties of the cells?
    BR
    Alkan

  • Re:Query for no.of days delayed using Receipt from production posting date.

    Dear SAP Experts,
    I need a query to calculate no of days delayed by using Receipt from production posting date and prod.order due date..i have already done the query but there is no link for joining the tables.Is there any link to join the tables..
    Plz Suggest a good query for this issue..
    With Regards,
    Revathy

    Dear Revathy,
    I think there is no need to link table if you just need calculate no of days delayed by using Receipt from production posting date and prod.order due date.
    You may check this query with the above:
    SELECT T0.ItemCode,T0.DueDate,
    T0.DocNum, T0.CloseDate,
    Datediff(dd,t0.DueDate,T0.CloseDate) Diff
    FROM dbo.OWOR T0
    WHERE  Datediff(dd,t0.DueDate,T0.CloseDate) > 0
    Thanks,
    Gordon

Maybe you are looking for

  • Memory On New Macbook

    Just how much is 1gb memory 80 gb harddrive. I'm a student. I don't play games on the computer, nor do i run any type of software other than MS word, excel, itunes, internet. Thats it.

  • Dynamic WHERE clause in SELECT statement

    Hi, I need to extract (SELECT) all the products in different salesorganizations. Since a product can be available in more than 1 salesorg I have created several properties in the PRODUCT dimension - 1 for each salesorganization (naming: Sxxxx where x

  • Actual cost is coming zero in service order

    Hi experts I am newer in CO.i can not recognise that "Actual cost is coming zero in service order".Please let me know that sollution thanks in advance sachin

  • Backup of iMovie

    If I make changes to a clip in the time line in iMovie, does time machine just make changes in the individual clip in the package or does it  backup the whle  package even though only a single change was made?  If the whole package, do you have any s

  • How to activate RoboHelp Office X4

    I have got RoboHelp X4 and want to activate it. The activation Wizard that I get while starting RoboHelp Office gives me two options - Internet activation and Manual activation through call center. First option of Internet activation always fails wit