Help, stuck on date range as cfreportparam

Hi all,
i'm running this and getting the follwing error:
Code:
<cfreport template="invoice_many.cfr" format="pdf" >
<cfreportparam name="from" value="2007-01-01">
<cfreportparam name="to" value="2008-01-01" >
</cfreport>
Error:
Report data binding error Incompatible java.lang.String value
assigned to parameter from in the ColdFusionReport dataset..'"
I've tried this in the report query:
.....query.....
AND orders.date_placed >= '#param.from#'
AND orders.date_placed <= '#param.to#'
as well as this:
....query....
AND <cfqueryparam value="#param.to#"
cfsqltype="CF_SQL_TIMESTAMP>
AND <cfqueryparam value="#param.to#"
cfsqltype="CF_SQL_TIMESTAMP">
no luck i'm stuck! Any ideas would be appreciated.. I'm in
Australia so not sure if this affects the date / time params as we
run date format dd-mm-yyyy..

Hi Create a date parameter like this.
Parameter fields->New->select type as date->in value field select your date field
Then in record selection formula write like this.
YourDateField <= {?Date}

Similar Messages

  • Neen help with date range searches for Table Sources

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 24-MAR-07, 22-SEP-), 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Need help with date range searches for Table Sources in SES

    Hi all,
    I need help, please. I am trying to satisfy a Level 1 client requirement for the ability to search for records in crawled table sources by a date and/or date range. I have performed the following steps, and did not get accurate results from Advanced searching for date. Please help me understand what I am doing wrong, and/or if there is a way to define a date search attribute without creating a LOV for a date column. (My tables have 500,00 rows.)
    I am using SES 10.1.8.3 on Windows 32.
    My Oracle 10g Spatial Table is called REPORTS and this table has the following columns:
    TRACKNUM Varchar2
    TITLE Varchar2
    SUMMARY CLOB
    SYMBOLCODE Varchar2
    Timestamp Date
    OBSDATE Date
    GEOM SDO_GEOMETRY
    I set up the REPORTS table source in SES, using TRACKNUM as the Primary Key (unique and not null), and SUMMARY as the CONTENT Column. In the Table Column Mappings I defined TITLE as String and TITLE.
    Under Global Settings > Search Attributes I defined a new Search Attribute (type Date) called DATE OCCURRED (DD-MON-YY).
    Went back to REPORTS source previously defined and added a new Table Column Mapping - mapping OBSDATE to the newly defined DATE OCCURRED (DD-MON-YY) search attribute.
    I then modified the Schedule for the REPORTS source Crawler Policy to “Process All Documents”.
    Schedule crawls and indexes entire REPORTS table.
    In SES Advanced Search page, I enter my search keyword, select Specific Source Group as REPORTS, select All Match, and used the pick list to select the DATE OCCURRED (DD-MON-YY) Attribute Name, operator of Greater than equal, and entered the Value 01-JAN-07. Then the second attribute name of DATE_OCCURRED (DD-MON-YY), less than equals, 10-JAN-07.
    Search results gave me 38,000 documents, and the first 25 I looked at had dates NOT within the 01-JAN-07 / 10-JAN-07 range. (e.g. OBSDATE= 10-MAR-07, 22-SEP-07, 02-FEB-08, etc.)
    And, none of the results I opened had ANY dates within the SUMMARY CLOB…in case that’s what was being found in the search.
    Can someone help me figure out how to allow my client to search for specific dated records in a db table using a single column for the date? This is a major requirement and they are anxiously awaiting my solution.
    Thanks very much, in advance….

    raford,
    Thanks very much for your reply. However, from what I've read in the SES Admin Document is that (I think) the date format DD/MM/YYYY pertains only to searches on "file system" sources (e.g. Word, Excel, Powerpoint, PDF, etc.). We have 3 file system sources among our 25 total sources. The remaining 22 sources are all TABLE or DATABASE sources. The DBA here has done a great job getting the data standardized using the typical/default Oracle DATE type format in our TABLE sources (DD-MON-YY). Our tables have anywhere from 1500 rows to 2 million rows.
    I tested your theory that the dates we are entering are being changed to Strings behind the scenes and on the Advanced Page, searched for results using OBSDATE equals 01/02/2007 in an attempt to find data that I know for certain to be in the mapped OBSDATE table column as 01-FEB-07. My result set contained data that had an OBSDATE of 03-MAR-07 and none containing 01-FEB-07.
    Here is the big issue...in order for my client to fulfill his primary mission, one of the top 5 requirements is that he/she be able to find specific table rows that are contain a specific date or range of dates.
    thanks very much!

  • Help with PowerShell to delete a date range of Calendar meetings

    I'm trying to delete all Calendar items within a date range, from a mailbox. But first I'd like to just make sure my date filter is actually working.
    Here is what i HAVE working:
    Search-Mailbox ME -SearchQuery "Received:01/01/2010..03/18/2010" -EstimateResultOnly
    This works, it gives me a count of all things in my mailbox
    Search-Mailbox ME -SearchQuery kind:meetings -EstimateResultOnly
    This works, it gives me a count of all Meetings in my Calendar.
    I reallly need now to get the date range to work in conjunction with the kind:meetings.
    How can I do that?

    Hi,
    The results include the deleted meetings. I test it in my lab.
    So the command to delete Calendar meetings with a date range is this:
    Search-Mailbox "username" -SearchQuery "Received:01/01/2010..3/18/2015 kind:meetings" –EstimateResultOnly -DeleteContent
    Best Regards.
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected]
    Lynn-Li
    TechNet Community Support

  • Help with Date Range

    Hi,
    I have an Oracle form which allows users to enter :start_date_active(mandatory) and :end_date_active (can be null).
    I need to check in form using SQL if there already exists a record for this date range or if there is any overlapping date ranges for the value entered and disallow user from entering that.
    I have my query as follows:
    SELECT (1)
    FROM <table> xsv
    WHERE 1=1
    AND ( (:START_DATE_ACTIVE >= xsv.start_date_active) AND
    (:START_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))
    OR
         (:END_DATE_ACTIVE >= xsv.start_date_active) AND
    (:END_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))
    But, this incorrectly allows me to enter over lapping date ranges when the :end_date_active is null.
    It should work as follows :
    eg.
    start_date_active end_date_active
    01-Apr-2009 allowed
    01-Mar-2009 10-Mar-2009 allowed
    01-feb-2009 Not allowed, as it overlaps with 1st record
    10-feb-2009 05-Mar-2009 Not allowed, as it overlaps with 2nd record
    05-Mar-2009 20-mar-2009 Not allowed, as it overlaps with 2nd record
    and so on.
    How do I modify my query to deal with null end dates ?
    Many Thanks
    Shankar

    Hi, Shankar,
    Whenever you have a question, it helps to post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (You posted this. It would be better if it were formatted.)
    (4) Your best attempt so far (formatted) (You posted this, but since it's unformated, it's very hard to read.)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    Formatted tabular output is okay for (3). Type these 6 characters
    &#123;code&#125;
    (small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
    Use different names for the parameters and the columns. For example, if the column is called start_date_active, call the corresponding parameter :p_start_date_active. It will help to keep them straight.
    In this statement, if the column end_date_active IS NULL, you're treating it as an impossibly late date:
    (:END_DATE_ACTIVE <= nvl(xsv.end_date_active,'31-DEC-4712'))That's good. (You should really use TO_DATE ('31-DEC-4712', 'DD-MON-YYYY'), though.)
    If it's possible for the parameter :end_date_active to be NULL, you should use NVL in the same way, to equate it with some appropriate date.
    The correct way to see if the range a to b (a <= b) overlaps with x to y (x <= y) is:
    WHERE   b >= x
    AND     a <= yIf you want an expression that's TRUE when they do not overlap, then say
    WHERE   NOT (    b >= x
                AND  a <= y
                )or, equivalently,
    WHERE   b < x
    OR      a > y

  • BEx Web Date Range Help

    Hi, I have a Web Report where the user inputs a Date Range Variable say 04/2009 - 03/2010.  Once the report appears I would like this range to appear at the top of the report and allow them to change it without having to go back to the variable selection screen.
    What do I need to do to get a field show the variable date range and allow them to change the date range as well?
    Thanks!

    Hi Kenneth,
    Are you in version 3.x or 7.x?
    This is easily achived in 7.x using the Command APIs. The idea is to offer a data selection element to the user. Once the user has changed the date element, then you can use the Command APIs to to change the variable/filter value. Take a look at this:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/71/8a784226d1d242e10000000a1550b0/frameset.htm
    Note that you can use the wizard to create the needed code or you can manually create the code yourself.
    Hope this helps.

  • Finding duplicates within a date range. SQL help please!!

    I have a table of records and I am trying to query the duplicate emails that appear within a given date range but cant figure it out.
    There records that it returns are not all duplicates withing the given date range.  HELP!!
    Here is my query.
    Thanks in advance.
    SELECT cybTrans.email, cybTrans.trans_id, cybTrans.product_number, cybTrans.*
    FROM cybTrans
    WHERE (((cybTrans.email) In (SELECT [email] FROM [cybTrans] As Tmp GROUP BY [email] HAVING Count(*)>1 ))
    AND ((cybTrans.product_number)='27')
    AND ((cybTrans.appsystemtime)>'03-01-2010')
    AND ((cybTrans.appsystemtime)<'03-05-2010')
    ORDER BY cybTrans.email;

    Yet another method...
    <cfset start_date = DateFormat('01/01/2007',
    'mm/dd/yyyy')>
    <cfset end_date = DateFormat('09/30/2009',
    'mm/dd/yyyy')>
    <cfset start_year = DatePart('yyyy', start_date)>
    <cfset end_year = DatePart('yyyy', end_date)>
    <cfset schoolyear_start = '09/01/'>
    <cfset schoolyear_end = '06/30/'>
    <cfset count = 0>
    <cfloop index="rec" from="#start_year#"
    to="#end_year#">
    <cfset tmp_start = DateFormat('#schoolyear_start##rec#',
    'mm/dd/yyyy')>
    <cfset tmp_end = DateFormat('#schoolyear_end##rec + 1#',
    'mm/dd/yyyy')>
    <cfif DateCompare(tmp_start,start_date) gt -1 and
    DateCompare(tmp_end, end_date) eq -1>
    <cfset count = count + 1>
    </cfif>
    </cfloop>
    <cfoutput>
    <br>There are #count# school year periods between
    #start_date# and #end_date#
    </cfoutput>

  • ICal sync- alert says will delete all past entries- Yes, I have my Keep Appointments set to "forever" AND I've tried changing the date range in desktop mgr- HELP

    I just did the update for the software on the 8530.  This is a new problem since the update.  I cannot lose my old entries, so I am unable to sync at all now until Blackberry addresses this bug.
    I have read through all of the "fixes" but none of them work.
    My Keep Appointments setting has always (and I verified is still) set to "forever"
    I went into the advance settings on the MAC desktop software from Blackberry and tried changing the date range to the suggested 14 days past and 365 days future.  I even tried changing the past days parameter to "1" in hopes it would simply ignore old entries... It still wants to delete 435 past entries.
    I have to keep these.
    Help, Blackberry!  Your "update" to the software is overriding my settings and has made the sync function unusable.

    Christina,
    Thanks for the reply. I unchecked all calendars in iCal and synced and it still gave me the same notice. So then I went into the iTunes window and checked the sync only certain calendars box (instead of the all calendars box) and left all the calendars unchecked and clicked apply but when I click on sync it automatically reverts to all calendars.
    When you say you unchecked all calendars did you mean in iCal? And what did you have your iCal settings at in your iTunes sync window?
    I appreciate your help,
    Andrea

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • Formula help - Group totals for more than one date range

    Post Author: melcaylor
    CA Forum: Formula
    I need to show in 3 columns
    inside of a grouping that totals an amount field based on a date
    range that amount was posted.  So for example:
    Billy Bob in the state of MA made $5.5m total, $800k in the last 21 days, $400k in the last 14 days and $150k in
    the last 7 days.
    I assume this is possible but I
    just donu2019t know what type of formula to write to make it work.  For this
    example, there are 2 tables u2013 user table and $$ table.  The User table has
    the user name, the $$ table has the pay date and the amount. 

    Post Author: SKodidine
    CA Forum: Formula
    You only need simple formulae in Running Totals to accomplish this.
    1.  Group by Name
    2.  Create the following Running Totals:
    2.1 A running total to sum the pay amount for all records, and resets on 'Change of Group' of Name.
    2.2 A running total to sum the pay amount and for 'Evaluate' click on the radio button next to 'Use a formula' and then click on X-2 button next to it.
    In the formula workshop window type a formula such as: {table.payment_date} in (currentdate - 21) to currentdate;
    For 'Reset' click on the radio button next to 'On change of group' and pick the group name.
    2.3 Create another running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 14) to currentdate;
    2.4 Create the last running total just as in step 2.2 above but change the formula to: {table.payment_date} in (currentdate - 7) to currentdate;
    Hide the details section and in the group footer place text boxes with appropriate text and insert these running totals to give you the numbers you want.
    The only issue I see with this is if a person was paid yesterday a sum of $25, then it will show $25 for total, last 7days, last 14days and also for last 21days.  At first look it might be mistaken for $75.

  • SqlQuery Help [date range]

    Database: Oracle 10g
    Table: SOURCE_TABLE
    #of records: 500k
    Primary Key: ID, EFF_DATE
    Data/Table:
    with SOURCE_TABLE AS
         (select 'P1' AS ID, TO_DATE('03/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID, TO_DATE('02/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V3' AS VALUE1, 'V24' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID, TO_DATE('01/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID, TO_DATE('03/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL)                                 
    SELECT * FROM SOURCE_TABLE  Conditions:
    For a given date range i.e. 01/01/2012 to 04/30/2012
    what we need is: For each ID, we need part "P" value1 and value2 column values for each specific month between the default date ranges.
    In this case it would be Jan-2012, FEB-2012, MAR-2012, APR-2012
    If you see below output for P1, there will not be JAN-2012 record as the part P1 is effective from FEB-2012
    What i have done so far:
    i have the select query basically it is looping through 01/2012 to 04/2012 and for every month,
    find out the max eff_date record less then the month that we are computing the value columns for
    Output:
    with output as
         (select 'P1' AS ID , '02/01/2012' AS AS_OF_DATE, 'V3' AS VALUE1, 'V24' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID , '03/01/2012' AS AS_OF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P1' AS ID , '04/01/2012' AS AS_OF_DATE, 'V1' AS VALUE1, 'V2' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '01/01/2012' AS AS_OF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '02/01/2012' AS AS_OF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '03/01/2012' AS AS_OF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL
          UNION ALL
          select 'P2' AS ID , '04/01/2012' AS AS_OF_DATE, 'V11' AS VALUE1, 'V21' AS VALUE2 FROM DUAL
    SELECT * FROM OUTPUT;
            ID     AS_OF_DATE     VALUE1     VALUE2
         P1     02/01/2012     V3     V24
         P1     03/01/2012     V1     V2
         P1     04/01/2012     V1     V2
         P2     01/01/2012     V10     V20
         P2     02/01/2012     V10     V20
         P2     03/01/2012     V11     V21
         P2     04/01/2012     V11     V21Thanks in advance

    Hi,
    ora1001 wrote:
    Hi frank,
    I changed the query to inner join instead of outer join because if a part is not effective for a given month, then i dont need a record.
    ex: if P1 EFF_DATE IS 03/01/2012, then i dont need records for JAN, FEB... You're right; inner join is all you need here. My mistake.
    What is "P1 EFF_DATE"? Is that the start of the date range you're interested in (January 1, 2012 in your original example)?
    Don't you still need to cosider rows before that date? For example, say we want to show the same 4 months (January to April, 2012), but instead of
    select 'P2' AS ID, TO_DATE('01/01/2012','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUALthe data is changed to
    select 'P2' AS ID, TO_DATE('11/01/2011','MM/DD/YYYY') AS EFF_DATE, 'V10' AS VALUE1, 'V20' AS VALUE2 FROM DUALWould you still want the same results? In this example, the values from November 2011 serve as the values for January and Febrruay 2012. It doesn't matter that Noverber 2011 is outside of the target range.
    It works fine... its faster now.
    however, i would like to know the difference in my query vs your query in terms of performance..
    the subquery runs faster when compared to analytic function...
    select * from part p,
    source_table st
    where p.id = st.id
    and st.eff_date = (select max(eff_date) from source_table st1
    where st1.eff_date < '01-mar-2012');
    If st1.eff_date is a DATE, then don't try to compare it to a VARCHAR2, such as '01-mar-2012'. Use TO_DATE:
    where st1.eff_date < TO_DATE ( '01-mar-2012'
                                   , 'DD-mon-YYYY'
                        )or a DATE literal:
    where st1.eff_date < DATE '2012-03-01'instead.
    vs
    select * from (
    select p.id,
    st.eff_date,
    row_number() over (partition by st.id,st.eff_date order by st.id,st.eff_date desc) as consider_order from part p,
    source_table st
    where p.id = st.id) where consider_order = 1;
    The first approach is doing much less work. It just has to remember what the latest eff_date is. Say it has already found a row with March 1, 2012, and it comes across a row with an earlier date, such as January 1, 2012. As soon as it sees that January 1, 2012 is not the new record holder, it can move on to the next row. (Using the LAST function, as I suggested, would cause it to do even less work.)
    The second approach is doing much more work. It has to remember all the dates, in order. Say it has already found a row with March 1, 2012, and it comes across a row with an earlier date, such as January 1, 2012. After it sees that January 1, 2012 is not the new record holder, it still has to determine if January 1 comes 2nd, or 3rd on the list.

  • **PLEASE HELP**Need Help adding date ranges to form

    I have designed a form with approximately 28 user defined date fields. I want the user to be able put in the first date range and then seautomaticaly fill in the other dates sequencially.
    ie,.... the user puts in 08/01/2007 then the following date field populates with 08/02/2007, then 08/03/2007 and so on....

    The following script can be used for the "exit" action so the basic action to get the start date's number and then it can be used to compute the next days field values by adding the appropriate number of days. A more experienced user could use a control loop t0 modify the field names and number of days to add to the start date's day number for the additional date fields.
    // Script for exit from date select field
    // perform calculation only if an input date has been selected
    if (HasValue(cInputDate)) then
    // format string for the date fields
    var cDateFormat = "MMM D, YYYY"
    // intermediate information start - optional
    xfa.host.messageBox(Concat("The input date formatted value is: ", cInputDate.formattedValue, "
    The input date's numeric value: ", Date2Num($.formattedValue, cDateFormat), "
    The adjusted date number is: ", (Date2Num($.formattedValue, cDateFormat) + 1), "
    The adjusted date is: ", Num2Date(Date2Num($.formattedValue, cDateFormat) + 1) ),
    "Intermediate Detail", 3, 0)
    // intermediate information end - optional
    var StartDateNumber = Date2Num($.formattedValue, cDateFormat)
    // add 1 day to StartDateNumber
    cAdjustDate = Num2Date(StartDateNumber + 1, cDateFormat)
    // add code for additional date fields here adding appropriate number of days for date
    else
    cAdjustDate = "" // no input keep field blank
    // add code for additional date fields here
    endif

  • Include weekends in date range

    Hello,
    I have a query that aggregates a value based on a date range and excludes business hours. I need to INCLUDE Saturday and Sunday based on the date range. I am stuck and I think I am at that time of day where your brain decides to quit. Time for some coffee :)
    Here is what I have so far and as always, thank you all very much for your help!
    declare @StartDate datetime, @EndDate datetime
    set @StartDate = '6/1/2013'
    set @EndDate = '6/30/2013'
    Select sum(abncalls)
    from TABLE
    where date between @StartDate) and (@EndDate)
    and starttime not in (800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630)
    Dave SQL Developer

    Something like this you are looking for
    Declare 
    @beginDate Date, 
    @EndDate Date 
    set @beginDate = '1/15/2014'
    set @EndDate = '1/30/2014'
    Declare @Calendar Table 
    (CalendarDate Date Primary key, IsWeekend Bit)
    While @beginDate <= @endDate 
    Begin
    Insert Into @Calendar 
      Select
        @beginDate As CalendarDate   
        ,(Case When DATEPART(Weekday, @beginDate) In (7, 1) Then 1 Else 0 End) As IsWeekend 
         Set @beginDate = DateAdd(Day, 1, @beginDate)
    End
    Select CalendarDate From @Calendar Where IsWeekend = 1 
    Select sum(abncalls)
    from TABLE
    where date in(Select CalendarDate From @Calendar Where IsWeekend = 1 )
    and starttime not in (800,830,900,930,1000,1030,1100,1130,1200,1230,1300,1330,1400,1430,1500,1530,1600,1630)
    -Prashanth

  • Difficulty working with overlapping date ranges and sums

    I have data like the following and need help querying it for a specific result:
    startdate             enddate               place     class       number
    03-30-2006          04-18-2006          A             22           2000
    04-01-2006          04-30-2006          A             22           6000
    03-30-2006          04-15-2006          B             11           1700
    03-15-2006          04-12-2006          B             11           2900
    I'd like to return the sum of the averages for any given day, by place, and by class, like this:
    day                    place     class       average
    03-15-2006          B             11           100
    03-16-2006          B             11           100
    03-30-2006          A             22           100
    03-30-2006          B             11           200
    03-31-2006          A             22           100
    03-31-2006          B             11           200
    04-1-2006            A             22           300
    04-01-2006          B             11           200
    04-30-2006          A             11           200
    I'm stuck, any help would be GREATLY appreciated.

    307b218a-cebe-46f1-87b6-946b4076ce79 wrote:
    Here is what I said in my original post:
    I'd like to return the sum of the averages for any given day, by place, and by class.....Then gave an example of output.
    I think that sentence describes the relations perfectly succinctly.
    How can it, when there's no SUM involved
    307b218a-cebe-46f1-87b6-946b4076ce79 wrote:
    For the date of 3-30-2006, the sum of the averages for region A in class 22 is 100, since from 3-30-2006 to 4-18-2006 is 20 days, and 2000/20 = 100, and there are no other class 22's in place A in that date range. Same goes for 3-31-20006.
    However for 4-1-2006 the sum of the averages is 300, since I have one record who's average is 100 (2000/20), and another (6000/30 = 200) and 200 + 100 = 300.
    For 4/30, I have one average in that range for place A class 22, and its average for that period is 200.
    Does that help?
    Much better, thank-you ..
    try this:
    WITH data AS (
          SELECT TO_DATE('03-30-2006','mm-dd-yyyy') startdate, TO_DATE('04-18-2006','mm-dd-yyyy') enddate, 'A' place, 22 class, 2000 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('04-01-2006','mm-dd-yyyy') startdate, TO_DATE('04-30-2006','mm-dd-yyyy') enddate, 'A' place, 22 class, 6000 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('03-30-2006','mm-dd-yyyy') startdate, TO_DATE('04-15-2006','mm-dd-yyyy') enddate, 'B' place, 11 class, 1700 cnumber FROM DUAL UNION ALL
          SELECT TO_DATE('03-15-2006','mm-dd-yyyy') startdate, TO_DATE('04-12-2006','mm-dd-yyyy') enddate, 'B' place, 11 class, 2900 cnumber FROM DUAL ),
       data2 AS ( SELECT startdate, enddate, enddate-startdate+1 numdays, place, class, cnumber
                   FROM data d
    SELECT startdate+x.lvl day, place, class, cnumber/numdays avg
      FROM data2 d,
          ( SELECT level lvl FROM dual CONNECT BY level <= 10000 ) x
    WHERE x.lvl <= numdays
    ORDER BY d.startdate, x.lvl
    It helps to be specific and detailed

  • How to get top 11 values per date range

    I want to get the top 11 values by date range.
    Sample Data
    CREATE TABLE SAMPLE_DATA
        DOMAIN_NAME VARCHAR2(100),
        QTD         NUMBER,
        LOAD_DATE   DATE
    -- Insert
    BEGIN
      FOR lc IN 1..20
      LOOP
        FOR ld IN 1..30
        LOOP
          INSERT
          INTO SAMPLE_DATA VALUES
              'DM_'
              ||lc,
              round(dbms_random.value(0,1000)),
              SYSDATE-ld
        END LOOP;
      END LOOP;
    COMMIT;
    END;
    SELECT *
    FROM
      (SELECT DOMAIN_NAME,
        QTD,
        LOAD_DATE
      FROM
        (SELECT DOMAIN_NAME,
          QTD,
          LOAD_DATE
        FROM SAMPLE_DATA
        WHERE LOAD_DATE = TRUNC(SYSDATE-3)
        ORDER BY QTD DESC
      WHERE ROWNUM <=10
      UNION ALL
      SELECT 'Others' DOMAIN_NAME,
        SUM(QTD) QTD,
        LOAD_DATE
      FROM
        (SELECT DOMAIN_NAME,
          QTD,
          LOAD_DATE
        FROM
          (SELECT rownum rn,
            DOMAIN_NAME,
            QTD,
            LOAD_DATE
          FROM
            (SELECT DOMAIN_NAME,
              QTD,
              LOAD_DATE
            FROM SAMPLE_DATA
            WHERE LOAD_DATE = TRUNC(SYSDATE-3)
            ORDER BY QTD DESC
        WHERE rn > 10
      GROUP BY LOAD_DATE
    ORDER BY QTD DESC
    -- Result
    DOMAIN_NAME                 QTD                         LOAD_DATE                  
    Others                      2888                        24/03/13                   
    DM_1                        1000                        24/03/13                   
    DM_20                       933                         24/03/13                   
    DM_11                       913                         24/03/13                   
    DM_3                        743                         24/03/13                   
    DM_13                       572                         24/03/13                   
    DM_12                       568                         24/03/13                   
    DM_9                        564                         24/03/13                   
    DM_6                        505                         24/03/13                   
    DM_5                        504                         24/03/13                   
    DM_2                        480                         24/03/13    
    Please, Help me get in one query this result using a range of date.
    e.g
    using LOAD_DATE BETWEEN '24/03/13' AND '25/03/13'
    DOMAIN_NAME                 QTD                         LOAD_DATE                  
    Others                      2888                        24/03/13                   
    DM_1                        1000                        24/03/13                   
    DM_20                       933                         24/03/13                   
    DM_11                       913                         24/03/13                   
    DM_3                        743                         24/03/13                   
    DM_13                       572                         24/03/13                   
    DM_12                       568                         24/03/13                   
    DM_9                        564                         24/03/13                   
    DM_6                        505                         24/03/13                   
    DM_5                        504                         24/03/13                   
    DM_2                        480                         24/03/13                     
    Others                      1948                        25/03/13                   
    DM_1                        807                         25/03/13                   
    DM_8                        764                         25/03/13                   
    DM_7                        761                         25/03/13                   
    DM_11                       656                         25/03/13                   
    DM_18                       611                         25/03/13                   
    DM_17                       523                         25/03/13                   
    DM_14                       467                         25/03/13                   
    DM_19                       447                         25/03/13                   
    DM_15                       437                         25/03/13                   
    DM_6                        380                         25/03/13             Thank you in advance.

    I got the solution. Just sharing.
    I used analytic functions that make my job easy.
    Sample Data
    DOMAIN_NAME                 QTD                         LOAD_DATE                  
    DM_1                        807                         25/03/2013                 
    DM_1                        1000                        24/03/2013                 
    DM_2                        226                         25/03/2013                 
    DM_2                        480                         24/03/2013                 
    DM_3                        244                         25/03/2013                 
    DM_3                        743                         24/03/2013                 
    DM_4                        48                          25/03/2013                 
    DM_4                        413                         24/03/2013                 
    DM_5                        164                         25/03/2013                 
    DM_5                        504                         24/03/2013                 
    DM_6                        380                         25/03/2013                 
    DM_6                        505                         24/03/2013                 
    DM_7                        761                         25/03/2013                 
    DM_7                        212                         24/03/2013                 
    DM_8                        764                         25/03/2013                 
    DM_8                        308                         24/03/2013                 
    DM_9                        354                         25/03/2013                 
    DM_9                        564                         24/03/2013                 
    DM_10                       214                         25/03/2013                 
    DM_10                       367                         24/03/2013                 
    DM_11                       656                         25/03/2013                 
    DM_11                       913                         24/03/2013                 
    DM_12                       37                          25/03/2013                 
    DM_12                       568                         24/03/2013                 
    DM_13                       332                         25/03/2013                 
    DM_13                       572                         24/03/2013                 
    DM_14                       467                         25/03/2013                 
    DM_14                       87                          24/03/2013                 
    DM_15                       437                         25/03/2013                 
    DM_15                       450                         24/03/2013                 
    DM_16                       238                         25/03/2013                 
    DM_16                       299                         24/03/2013                 
    DM_17                       523                         25/03/2013                 
    DM_17                       143                         24/03/2013                 
    DM_18                       611                         25/03/2013                 
    DM_18                       145                         24/03/2013                 
    DM_19                       447                         25/03/2013                 
    DM_19                       464                         24/03/2013                 
    DM_20                       91                          25/03/2013                 
    DM_20                       933                         24/03/2013                  Top 11 QTD of DOMAIN_NAME per Data Range.
    SELECT *
    FROM
      (SELECT DOMAIN_NAME,
        QTD,
        LOAD_DATE
      FROM
        (SELECT LOAD_DATE,
          DOMAIN_NAME ,
          QTD,
          (DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
        FROM SAMPLE_DATA
        WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
      WHERE RANK_QTD <= 10
      UNION ALL
      SELECT 'Others',
        SUM(QTD) AS QTD,
        LOAD_DATE
      FROM
        (SELECT LOAD_DATE,
          DOMAIN_NAME ,
          QTD,
          (DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
        FROM SAMPLE_DATA
        WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
      WHERE RANK_QTD > 10
      GROUP BY LOAD_DATE
    ORDER BY LOAD_DATE ASC,
      QTD DESC
    DOMAIN_NAME                 QTD                         LOAD_DATE                  
    Others                      2888                        24/03/2013                 
    DM_1                        1000                        24/03/2013                 
    DM_20                       933                         24/03/2013                 
    DM_11                       913                         24/03/2013                 
    DM_3                        743                         24/03/2013                 
    DM_13                       572                         24/03/2013                 
    DM_12                       568                         24/03/2013                 
    DM_9                        564                         24/03/2013                 
    DM_6                        505                         24/03/2013                 
    DM_5                        504                         24/03/2013                 
    DM_2                        480                         24/03/2013                 
    Others                      1948                        25/03/2013                 
    DM_1                        807                         25/03/2013                 
    DM_8                        764                         25/03/2013                 
    DM_7                        761                         25/03/2013                 
    DM_11                       656                         25/03/2013                 
    DM_18                       611                         25/03/2013                 
    DM_17                       523                         25/03/2013                 
    DM_14                       467                         25/03/2013                 
    DM_19                       447                         25/03/2013                 
    DM_15                       437                         25/03/2013                 
    DM_6                        380                         25/03/2013 

Maybe you are looking for

  • Image files getting truncated error

    I am a photographer ... upgraded to mountain lion 10 days ago....some of the image files after processing get a truncated error...I have reinstalled PS6 - LR 4 - Proselect...used two different cards and ran utilities disk check -- did not correct pro

  • Finder crashes all the time

    Since last friday I got a problem. When I try to open a file or even look for the specifics of a file Finder crashes and I need to restart it. When I open the files with excel or word or something everything is OK. I never had this problem before. Ca

  • ALV  object  model examples

    Dear All Can anybody tell me, where will i find the examples for ALV report using object model (two-dimensional table). Thanks ravi

  • Is anyone having trouble with the "home" button not responding after upgrading to 5.1.1 OS?

    Is anyone having problems with the "home" button not responding after upgrading to 5.1.1?

  • Usage of / is 97%

    Hi, In my solaris 10 developement box / usage is showing as 97%...below the details..pls suggets what can be deleted to free up space under / # df -h Filesystem size used avail capacity Mounted on /dev/md/dsk/d10 15G 14G 521M 97% / /devices 0K 0K 0K