How to use date or year as optional parameters

Post Author: [email protected]
CA Forum: Data Connectivity and SQL
I have a summary report that the user can either select a date range or the year to get a summary report. I am trying to limit in the actual SQL as I don't want date as one of the columns, otherwise my summary won't work. I could have the year be a column and then have the parameter in a selection formula. But as to the date what would be the syntax in the SQL?  What I have for developer is the following, but that does not seem to work.
and trans_date >= nvl(:p_beg_date, trans_date) and trans_date <= nvl(:p_end_date, trans_date)
I am a newbie on Crystal Reports using version 2008 so any suggestions would be appreciated.
Thanks,Trish Leppa
John I. Haas, Inc

Post Author: Maxim6469
CA Forum: Data Connectivity and SQL
Try this:
Where (trans_date >= {?p_beg_date} and trans_date <= {?p_neg_date}) or Year(trans_date) = {?year}
This is assuming that you created 3 parameters in SQL called: p_beg_date, p_neg_date, and trans_date.

Similar Messages

  • How to  use data function using characterstics variable for calculation on

    how to  use data function using characterstics variable for calculation on  attribute as key figure

    Hi Gayatri
    Did you not see my answer for CASE because CASE does indeed offer the use of the BETWEEN clause, but DECODE does not. Let me give you a little synopsis of DECODE.
    In its most simple form it takes 4 values and looks like this: DECODE(A, B, C, D)
    This essentially means, IF A = B THEN C ELSE D
    The trick to solving BETWEEN in a DECODE is to work out algoriths where A = B. Because we don't know how many values are between 00 and 99, although I could guess there were 100 we could of course have 100 parts in the DECODE but that would be awful. How about if we look at it another way and say this:
    IF PART_NUMBER < 'SDK00' THEN pay_amount
    ELSE IF PART_NUMBER > 'SDK99' THEN pay_AMOUNT
    ELSE pay_amount + 100
    This statement only had 2 hard coded values, but how to make DECODE work with less than? Easy, we use the LEAST function. The LEAST function takes 2 values and returns the one with the lowest value. So I use LEAST(PART_NUMBER, 'SDK00') then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the opposite function GREATEST. Putting all of this together then, you can do this:
    DECODE(PART_NUMBER, GREATEST(PART_NUMBER, 'SDK00'), DECODE(PART_NUMBER, LEAST(PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)
    In English this can be read as follows:
    IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0
    Best wishes
    Michael

  • How to change date format in select-option (mm.yyyy).

    Hi,
       Plz, How to change date format in select-option (mm.yyyy).
      in my selection screen date type selection-option is there ,when i am enter date   it's  taken  dd.mm.yyyy format,but i want mm.yyyy format.
    how to set that .
    Regards,
    Kk.

    sorry
    parameters : pmonyr type spmon or
    select-options : sspmon for PGPL-spmon .
    or what table ccontains spmon.
    regards
    shiba dutta

  • Can u  tell me any of you how to use Date class

    Can u tell me any of you how to use Date class. Please send me the source code.

    People won't send you the source code.
    Ask specific questions. You are very vague.
    Tell me how to build.

  • How to use Date data type ?

    Hi @,
    I have to use date type in my datatype but the format for the same is different and i dont know where to specify the same please help?
    Also how to define datetime type with format yyyy-mm-dd.Thh:mm:ss ?
    If there any place to specify the format ? I have defined it in pattern ?please correct
    Regards

    Hi
    I guess you can do it message mapping by defining source and destination date types, using date functions currentDate, DateTrans, DateBefore, DateAfter, CompareDates
    By default, format of date is
    xsd:date
    Value is interpreted as date in format CCYY-MM-DD (according to the enhanced representation of ISO 8601).
    The abbreviations mean the following:
    CC: Century
    YY: Year
    MM: Month
    DD: Day
    Regards,
    Sai

  • How to use data from standard view in Web dynpro for ABAP

    Hello:
    I have to create an Abap Web Dynpro, and I must use data from a standard view in the new one. Does anybody know what do I have to do?
    Thank you and have a happy new year.

    Hi Rodrigo,
    Firstly, list the Standard component under Component Usage of the Component which you are creating in your View.
    Second, In the Custom Component, view, goto context, and try to add the node from the Standard component in to your view.
    NOTE: The second step requires a Node in component controller of the Standard Component.
    Finally, Now in your view, get the data from that and map the data.
    NOTE: To do this, I think you need to call your Standard WDA first and then only your node contains data and it will be passed.
    I hope it is helpful.
    Regards,
    Shashikanth. D

  • How to use dates/times in the definition of local fields?

    Hello!
    I have few tough questions for which I haven't found an answer. I hope someone is capable to help me.
    1. Is there a transaction to search tables if we know the field?
    2. I'd like to define a local field and need to use dates in the calculation function. So basically I need to calculate the lean-time from the date of the purchase order (field BSTDK) to the date of the final delivery (field PLIFTS) and the result should be displayed in weeks. How can I do this? Or can I?
    3. Can I use the local fields further in my calculations?
    Thank you in advance!
    Maria Kangasniemi

    Hi,
    1. Is there a transaction to search tables if we know the field?
    Tcode:    SE84
    2. I'd like to define a local field and need to use dates in the calculation function. So basically I need to calculate the lean-time from the date of the purchase order (field BSTDK) to the date of the final delivery (field PLIFTS) and the result should be displayed in weeks. How can I do this? Or can I?
    Doing some calculation you can define it.
    3. Can I use the local fields further in my calculations?
    What is local Fields?

  • How to use date functions in BPEL

    Hi All,
    Is there any wayout for calculating no. of years with a given date and current date in BPEL.
    I am developing a small application where I have to calculate the years of experience of the employees. I am given with the date of joining.I want to subtract the date of joining from the current date. Is there any way-out to calculate no. of years from the given date and current date in BPEL using date functions or something else.
    Please suggest something..
    Thanks in Advance
    Roshni Shankar

    you could use something like this in xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
         <xsl:output method="xml"/>
         <xsl:variable name="date1" select="xs:date('2001-01-01')"/>
         <xsl:variable name="date2" select="xs:date('2010-01-10')"/>
         <xsl:variable name="dif" select="$date2 - $date1"/>
         <xsl:template match="/">
         <all>
              <date1>
                   <xsl:value-of select="$date1"/>
              </date1>
              <date2>
                   <xsl:value-of select="$date2"/>
              </date2>
              <dif-days><xsl:value-of select="fn:days-from-duration($dif)"/></dif-days>
              <dif-years1><xsl:value-of select="fn:years-from-duration($dif)"/></dif-years1> <!-- gives 0 for me -->          
              <dif-years2><xsl:value-of select="fn:days-from-duration($dif) div 356"/></dif-years2>                    
              </all>
         </xsl:template>
    </xsl:stylesheet>

  • How to use Data Navigation in OBIEE11g

    Hi,
    I read an article about BIEE 10g feature: Data Navigation (click on a record in Analytics report1 and corresponding drill down data show in Analytics report2). I found that there are some setting "Type: Navigate" in "Value Interaction" should be set in Tab: "Column Format" of Column properties in BIEE 10g (pls refer to: http://gerardnico.com/wiki/dat/obiee/navigation).
    However, I didn't find these setting in OBIEE 11g. How do I use Data Navigator in OBIEE 11g? Is this features is disabled?

    *1. Firstly, what means of "Column (should be filtered)?*
    The column in Criteria you should give the *Filter*
    2. Table.Column -> Column Properties -> Interaction -> Value (Primary Interaction) -> Action Links -> Add (+ Symbol in Green color) -> Action -> Click *Navigate to BI Content* -> Select the Report from the Shared folder -> OK and Save the report.
    Thanks,
    Balaa...

  • How to use date column index

    Hi,
    Why is that I got different results for my queries?
    Note that emp_date is indexed, so i dont want to use
    a function to it.
    QUERY1(full table scan)
    SELECT COUNT(*) FROM EMP WHERE TRUNC(EMP_DATE)=TRUNC(SYSDATE-30); (RESULT=8,842)
    QUERY2
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE >=(SYSDATE-30) and EMP_DATE < (SYSDATE-30); (RESULT=0)
    QUERY3
    SELECT COUNT(*) FROM EMP WHERE
    EMP_DATE BETWEEN TRUNC(SYSDATE-30) and TRUNC(SYSDATE-30); (RESULT=2,100)
    Please help me how to use indexed date column...

    > Why is that I got different results for my queries?
    Because your queries are different.
    1) This one selects all records on 20 october, regardless of their time component
    2) This one selects all records with an emp_date at least being 20 october 14:56:30 AND being smaller than 20 october 14:56:30. No record will ever satisfy this condition.
    3) This one selects all records on 19./20 october at midnight 00:00:00
    Please see this example:
    SQL> create table myemp (emp_date)
      2  as
      3   select trunc(sysdate) - 30 +
      4          case
      5          when level <= 2100 then 0
      6          when level <= 8842 then dbms_random.value(1,86399)/86400
      7          else 2
      8          end
      9     from dual
    10  connect by level <= 100000
    11  /
    Tabel is aangemaakt.
    SQL> create index i1 on myemp(emp_date)
      2  /
    Index is aangemaakt.
    SQL> exec dbms_stats.gather_table_stats(user,'myemp',cascade=>true)
    PL/SQL-procedure is geslaagd.
    SQL> set autotrace on explain
    SQL> select count(*) from myemp where trunc(emp_date)=trunc(sysdate-30)
      2  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=88 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     TABLE ACCESS (FULL) OF 'MYEMP' (Cost=88 Card=1000 Bytes=
              8000)
    SQL> select count(*) from myemp where
      2  emp_date >=(sysdate-30) and emp_date < (sysdate-30)
      3  /
                                  COUNT(*)
                                         0
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    SQL> select count(*) from myemp where
      2  emp_date between trunc(sysdate-30) and trunc(sysdate-30)
      3  /
                                  COUNT(*)
                                      2100
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)
    > Please help me how to use indexed date column...
    Use this query instead:
    SQL> select count(*)
      2    from myemp
      3   where emp_date between trunc(sysdate)-30 and trunc(sysdate)-29 - interval '1' second
      4  /
                                  COUNT(*)
                                      8842
    1 rij is geselecteerd.
    Uitvoeringspan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1 Bytes=8)
       1    0   SORT (AGGREGATE)
       2    1     FILTER
       3    2       INDEX (RANGE SCAN) OF 'I1' (NON-UNIQUE) (Cost=4 Card=2
              50 Bytes=2000)Regards,
    Rob.

  • How to use data-sources tag in struts-config.xml

    hi all,
    I am doing programs in sturts. My program purpose is to retrieve data from the database.My database is MySql. I know that we can write connection code in Action Class, it is ok for some less prog's if i want to use the sane connection code in more Action Classes it is vasting time and so.
    So i want to use <data-sources> tag that is available in struts-config.xml. I know that thre is tag with this name, but the problem is i don't know how to use this tag. If any budy know how to use this please tell me the syntax or any example.
    plese... reply soon..

    hi all,
    I am doing programs in sturts. My program
    My program purpose is to retrieve data from the
    database.My database is MySql. I know that we can
    write connection code in Action Class, it is ok for
    some less prog's if i want to use the sane connection
    code in more Action Classes it is vasting time and
    so.I don't think it's a good idea to put database code in Action classes. (That's one of the biggest drawbacks of Struts - it's completely tied to Actions, HTTP, and the Web.) Better to move that code into plain old Java objects and let the Actions call them.
    You'll be able to test them without the container or Struts, and you'll be able to reuse those objects in other, non-Web contexts.
    So i want to use <data-sources> tag that is available
    in struts-config.xml. I know that thre is tag withThis is the wrong place to configure a connection pool, too. Struts should have nothing to do with it. What if you change Web frameworks to WebWork or Spring? The connection pool should be configured in the container that hosts your app, not Struts.
    this name, but the problem is i don't know how to use
    this tag. If any budy know how to use this please
    tell me the syntax or any example.
    plese... reply soon..Don't do it. Think about doing it in your container, not Struts.
    %

  • How to use data sets with smart objects?

    Hi,
    I have a psd of some mock-up boxes, and I want to apply different text to multiple versions. The solution here: http://helpx.adobe.com/photoshop/using/creating-data-driven-graphics.html is good, but doesn't seem to work with smart objects?
    The file that I have has the box label as a smart object (which opens as a psb). How could I apply a data set to that, and have it pump out multiple jpegs?
    If I apply the data set to the psb layers, then go back to the main image, I cannot export the whole complete picture anymore.
    Thanks!

    What database and connection type are you using? Are you connecting the report directly to the database, or trying to assign the datasource to object data?
    It sounds like you might be trying to use a linked list, collection or other C# construct to pass your data in. This currently isn't supported by the Crystal Reports SDK. You can use a DataSet or a DataTable, and possibly also an IDataReader depending on which version of Crystal Reports you're referencing in your project. Of course you can also connect directly to the database, even if the database isn't on the same machine as the application.
    The way to show master records with detail information is through the use of subreports and linked subreport parameters. Linked subreports take their parameter value from a record in the main report, so that only the data appropriate to that master record is displayed. The guys over in the [report design|SAP Crystal Reports; forum can help you out with this if you have questions on the specifics.

  • How to use Data Mining for a blind DBA?

    Hi, I'm a blind DBA and I need some input and some suggestions from the forum on how to access the Data Mining feature.
    This feature is becoming more and more an essential part of my daily tasks, so I need a way to use it.
    Database: Oracle 11.1.0.7.0
    OS: Windows XP Pro and Linux
    Adaptive Technology:
    JAWS Version 11.0.1467 by Freedom Scientific BLV Group, LLC
    JAVA Access Bridge by SUN Microsystems
    I know there is a Windows program called Data Miner, unfortunately my JAWS speech synthesizer does not work with the interface and I need an alternative. I
    read Oracle's documentation on the Data Miner API., but it is short on examples, details , and step by step instructions. Does anyone have a more
    comprehensive set of examples on how to use the Data Mining API. from start to finish, specifically for market basket analysis? Any help would be
    appreciated.
    Thanks.

    Hi,
    I am not very knowledgeable about Oracle Data Miner, the graphical user interface to Oracle Data Mining, but I can respond to your question about API documentation.
    You may find the source files for the Data Mining sample programs to be very helpful. They provide many examples. After installing Oracle Database, install Oracle Database Examples. This separate installation process installs the sample programs in the DEMO directory under Oracle Home. Instructions for installing and configuring the sample programs are provided in Oracle Data Mining Administrator's Guide. Here is the link to the relevant chapter in the 11.1 Administrator's Guide.
    http://download.oracle.com/docs/cd/B28359_01/datamine.111/b28130/sampleprogs.htm#BABEHFEB
    As for the API documentation, the best place to start is probably the Data Mining Application Developer's Guide. Here is the link to the 11.1 Application Developer's Guide.
    http://download.oracle.com/docs/cd/B28359_01/datamine.111/b28131/toc.htm
    The Data Mining PL/SQL API for creating data mining models is implemented in the DBMS_DATA_MINING package. The syntax of Oracle PL/SQL packages is documented in PL/SQL Packages and Types Reference. Here is the link to the chapter in the 11.1 version of that manual.
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_datmin.htm#i1062150
    The Data Mining functions for scoring (applying mining models to new data) are implemented as SQL functions. The syntax of Oracle SQL is documented in SQL Language Reference. Here is the link to the Data Mining SQL functions in the 11.1 version of that manual.
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/functions001.htm#sthref953
    Hope this helps,
    Kathy
    Edited by: ktaylor on Nov 10, 2010 8:14 AM

  • How to use date and time

    hello,
    how can i use date and time in windows platform for export dumpfile.

    you can use this..
    C:\>echo backup_daily_%date:~4,2%_%date:~7,2%.log
    backup_daily_03_12.log
    may be you will have to adjust ~values to show proper values.
    Hope that will help you
    Anil Malkai

  • New to OATS,need info on how to use data bank

    Hi,
    Please share some documents/links on how to use OATS for web functionality testing,and how to use databank.
    Thank you,
    Raju

    Hi,
    I am using OATS version: 9.10,Can someone tell me on how to use Databank for parameterization.If possible please share some document which has all the steps.
    Thank you,
    Raju

Maybe you are looking for