How would you send a date-range parameter to a SQL sproc?

Team,
MY ENVIRONMENT
SQL 2005, Crystal Reports for Visual Studio 2005
MY PROBLEM
I am authoring both a sproc and a report, so I have full control over the design. I am a SQL expert and also a Crystal 8.5 expert.
I have done the Sproc-Report connection dozens of times.
Please consider along with me the sequence of creating a report based on a parameterized stored procedure.
My sproc header is shown here:
CREATE Procedure dbo.usp_DocumentActivityReport(
     @Department NVARCHAR(50)      
   , @DateRange  NVARCHAR(50)
) AS
SELECT Col1, Col2, Col3 FROM #TEMP
MY THOUGHT PROCESS
@DEPARTMENT is a string. That's easy.
@DATERANGE is a DATE RANGE and I don't know how to get Crystal Reports to prompt for a date range, so I used a String parameter knowing I can parse a specially formatted string, and knowing that I can use a formula to compute the string.
Step 1. Create the blank report, the {?Department} parameter, the {?CreationDateRange} report parameter, and the {@DateRangeText} conversion formula that converts {?CreationDateRange} to the specially formatted string.
Step 2. Test the stored procedure.
Tests pass; It returns data when I run it with values, with zero-length string values, and with NULL values.
Step 3. Tie the report to the stored procedure.
Adding the sproc directly creates two hard-wired, undeletable parameters, and returns data columns. That's no good because the user must supply the specially formatted string for the date range. So, I try using Add Command instead, with this syntax:
{call "EXP_TEST"."dbo"."usp_CorroDocumentActivityReport" (N'{?Department}', N'{@DateRangeText}')}
This code is accepted, but Add Command did not create any undeletable parameters at all. I guess that's OK.
But the worst part is that it does not show any output columns with data either! AAARGH!
Please assist with showing me the proper order to do these steps.
BTW, here's the VB Syntax formula for {@DateRangeText}:
Dim min As String
dim max as String
if HasLowerBound ({?CreationDateRange}) then
  min = ToText(Minimum({?CreationDateRange}),"MM/dd/yyyy")
else
  max = ""
end if
if HasUpperBound ({?CreationDateRange}) then
  max = ToText(Maximum({?CreationDateRange}),"MM/dd/yyyy")
else
  max = ""
end if
if IncludesLowerBound ({?CreationDateRange}) then
  min = "[" & min
else
   if HasLowerBound ({?CreationDateRange}) then min = "(" & min
end if
if IncludesUpperBound ({?CreationDateRange}) then
    max = max & "]"
else
   if HasUpperBound ({?CreationDateRange}) then max = max & ")"
end if
'formula = min & "..." & max
formula = "(1/1/2009...3/1/2009)"
sorry ... cross-posted per Amit

Ludek,
It sounds like you and The specified item was not found. think along the same lines! I have cross-posted for both of you now!
Please see Simple Sproc Parameters question
~ Shaun

Similar Messages

  • How do you send a date from java to a stored procedure

    Oracle 8.0.5
    using thin drivers
    I'm trying to pass a date to a stored procedure. Does anybody
    have an example of how to do this.
    I want to send a month-day-year 01/01/1999 to oracle to be
    inserted into the table. what should the java code look like?
    and what should the (in) line look like in oracle.
    Thanks
    Kirk
    null

    Wow. You got me there.  All of the pdfs that i have, when i tap that icon, open a drop down window with the choices of e mail or print.  I wonder if the particular pdf you are working on is somehow protected?  Try a different pdf and see if the box recats the same way.   You might also do a full shut down and just try again.  Make sure there is not an old instance of i books, or some other pdf editor sitting in the task bar, by doblue clicking the home button, and shutting down any open apps.

  • How would you present summary data?

    I have this spreadsheet that queries 6 different databases (on 6 different servers)- the spreadsheet then takes the output in each worksheet and does a comparison which then highlights missing
    data between the sheets. I'd like to make a more "user-friendly" console (like a web browser) that will display this summary data. Ideally, the end-user could then select two distinct sources from some drop-down menu and invoke the resultant records
    from the chosen comparison.
    Is this something that I could/should do in SSRS? ...SharePoint list? Might there even be a more creative way using PowerShell to scrub csv files and front-end with a web page (seems kludgy)?
    I'm no pro at any of these but want to direct my efforts at the most logical solution.

    I'd ask in the development forums on MSDN.
    https://social.msdn.microsoft.com/Forums/en-US/home
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • How would you read in each line of data and display them to message box?

    How would you read in each line of data from the _.txt file_ and display the whole data using an information-type message box?
    I know how to display each line of the .txt file data, but I do not know how to display the whole thing.
    Here is how I did to display each line of data using the message box:
    import javax.swing.JOptionPane;          // Needed for the JOptionPane class
    import java.io.*;                         // Needed for file classes
    public class problem3
         public static void main(String[] args) throws IOException
              String filename;          // Needed to read the file
              String categories;          // Needed to read the categories
              // Get the filename.
              filename = JOptionPane.showInputDialog("Enter the filname.");
              // Open the file.
              FileReader freader = new FileReader(filename);
              BufferedReader inputFile = new BufferedReader(freader);
              // Read the categories from the file.
              categories = inputFile.readLine();
              // If a category was read, display it and
              // read the remainig categories.
              while(categories != null)
                   // Display the last category read.
                   JOptionPane.showMessageDialog(categories);
                   // Read the next category.
                   categories = inputFile.readLine();
              // Close the file.
              inputFile.close();
    }I think I need to change here:
    // If a category was read, display it and
              // read the remainig categories.
              while(categories != null)
                   // Display the last category read.
                   JOptionPane.showMessageDialog(categories);
                   // Read the next category.
                   categories = inputFile.readLine();
              }but I don't know how to.
    Could you please help me?
    Thank you.

    kyorochan wrote:
    jverd wrote:
    What is not understood about your question is which part of "read a bunch of lines and display them in a textbox" do you not understand.
    First thing's first though: You do recognize that "read a bunch of lines and display them in a textbox" has a few distinct and completely independent parts, right?I'm sorry. I'm not good at English, so I do not understand what you said...
    What I was trying to say is "How to display the whole lines of .txt file in single dialog box."We know that.
    Do you understand that any problem can be broken down into smaller pieces?
    Do you understand that your problem has the following pieces?
    1. Read lines from the file.
    2. Put the lines together into one String.
    3. Put the String into the message box.
    and maybe
    4. Make sure the message box contents are split into lines exactly as the file was.
    (You didn't make it clear if that last one is a requirement.)
    Do you understand that 1-4 are completely independent problems and can be solved separately from each other?
    Do you understand that you have stated that you already know how to do 1 and 3?
    Therefore, you are NOT asking "How to display the whole lines of .txt file in single dialog box." Rather, you ARE asking either #2 or #4 or both.
    If you say once more "display all the lines of the file in one dialog box," then it is clear that we are unable to communicate with you and we cannot help you.

  • How would you go about retrieving your backed up data?

    How would you go about retrieving your backed up data from the Time Capsule?
    I have mine on auto back up (initial back up took 3 days)

    Time Machine FAQ

  • Dates : How would you do this.

    mx:DateChooser has a selectableRange property where you can set a rangeStart and a rangeEnd...
    Is it possible, or how would you go about doing it so it's a nonSelectable range.
    a user clicks on 3 days, so the calendar marks that off, so another user won't be able to select those same 3 days type of thing...

    d'oh
    .disabledRanges
    *SIGH*

  • Date Range Parameter's Restriction

    Could you someone please tell me how BO restricts date range parameter when the users tries to run a query?  Often times, users simultaneously try to get several years of data dumped into a single query.  Some users even forget to enforce the date range, which causes the query to try to get the data from the beginning of time. 
    How do we as a BO developer create some sort of date range restriction so that it can prevent users from overloading a query?  If the users want to get several years of data, he/she has to run a query in batches instead of doing it all at once.
    I hope there is a way that we can create a custom informational error message for each report to prevent users from trying to query too many months or years of data.  Some reports may hit small and well-indexed tables that allow large date range queries.  But, some reports query against large and poorly indexed tables, which can potentially cause adverse effect on performance without date range restriction. 
    Any thoughts or advices on how to implement such things (if possible).  I am also afraid that the answer will be "currently not doable".  If so, any ideas if the next version of BO will allow such functionality, or if it is at least in the plan at all?  Thank you so much for your insight and sharing.  Have a great day!

    Dear Amr,
    Thanks so much for your quick reply!  The field I want to create a restriction on is called RESULT_DT_TM.  When I saw the "where" section of the field, I just don't see how I can apply my START_DT_TM and END_DT_TM parameters on this field so that START_DT_TM and END_DT_TM cannot be more than 365 days apart.  If my query does not use parameters called START_DT_TM and END_DT_TM, this "where" section will not be valid? 
    I don't think the solution has to be on the field itself but rather on the parameter START_DT_TM and END_DT_TM.  What I want is that as long as START_DT_TM and END_DT_TM are more than 365 days apart, it does not matter what field these parameters are running against. The screen would then display something saying "your date range parameters for this report must be within 365 days.  Please revise your date range on query".
    Sorry, I am PL/SQL report programmer, and not familiar with what BO can do.  So, is there anyway that can make my dream come true?  Thanks a bunch again, Amr.

  • Regarding Date Range parameter

    hello,
    in purchase order, i want to pass date range parameter. For eg .
    I want to fetch data from 21/11/2011 to 25/11/2011
    how to pass parameter for this?? or do i need to create any formula??
    if yes then how/???????
    awaiting for soonest reply.

    hi,
    you need to do this in the Formula workshop.
    this formula {OPOR.DocDate} = {?DateRange}
    {OPOR.DocDate} - this is the PO DocDate
    {?DateRange} - this is what you have done in step #4 in my 1st post. in this example "DateRange" is the name of my Parameter.
    Quote from you post
    {OPOR.DocDate} = {?25/11/2011 to 30/11/2011} In this way should i write a formula??????
    change this {?25/11/2011 to 30/11/2011} to the name of your Parameter. refer to step #4.
    regards
    Fidel

  • Pass date range parameter  to SQL stored procedure.

    Hi,
    I'd like to pass a date range parameter from Crystal Reports to a sql stored procedure. Does anyone know if this is possible?
    I've had no problem passing standard datetime (single value) paramaters to and from but am struggling with getting a range value parameter to work.
    Environment: Crystal Reports 10/XI and SQL 2000 MSDE version or SQL 2005 Express Edition.
    Any help would be appreciated.

    C5112736 wrote:>
    > And then these 2 formulas 'Formula # 1' and 'Formula # 2' can be used to pass on to the stored procedure.
    Can someone please demonstrate exactly how to use formula results as date parameters to a SQL stored procedure?  Keep in mind, there are two parameters to the stored procedure.
    I have gleaned this much: Use Add Command and insert the procedure with
    EXEC ServerName.dbo.usp_sprocName;1 '{?StringParameter}'
    but if I try to do
    {CALL ServerName.dbo.usp_SprocName({@Formula1},{@Formula2})}
    then it gives the error "No value given for one or more required parameters". 
    Both of the parameters are VARCHAR(50).
    I have finally found this link: [http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx|http://msdn.microsoft.com/en-us/library/ms710248(VS.85).aspx]
    This Microsoft site defines the format of the ODBC escape sequences, but I still do not know how to convince Crystal to insert it's parameter results or formula results.
    Pulling what's left of my hair out . . .
    ~ Shaun

  • How would you configure your database?

    How would you configure your disks with those specifications?
    General Database Characteristics:
    os is Oracle Enterprise Linux 64 bit
    Enterprise Edition
    180GIG size database.
    High "oltp" environment.
    Estimated growth of 40 to 60GIG/year
    20GIG of archivelogs/Day
    Flashback time is 24 hours:120GIG of flashback space in avg
    Local backup. Full database copy, then incremental is the preferred method.
    That way, if a datafile goes bezerk, replace with backup datafile then recover.
    Or if only a few corrupt block, block recover with rman.
    BTW: Backup is done locally first, then send to another server, than on tape.
    Archivelogs is duplexed on another server.
    General Hardware Info:
    Server Platform: Dell PowerEdge 1950
    16 GIG RAM
    2 * 64 bit CPU's
    2 * local 300G/15rpm disks
    Storage: Dell PowerVault MD3000
    15 * 300G/15rpm Disks
    Possibility for 17 disks here.
    Here is my configuration so far:
    OS+ oracle binary + Online Redo Logs Copy 1 + Control File Copy 1: 2 disks raid 1
    flashback + backup + Online Redo Logs Copy 2 + Control File Copy 2: 4 disks raid 1 or 10
    archivelogs: 2 disks raid 1
    Temporary Datafiles: 1 disk no raid
    UNDO Datafiles: 2 disks raid 1
    Datafiles 6 disk raid10
    total 17 disks: + spare disks on the side of one ever fails
    1) How would you configure it with those specs?
    2) Is there missing info to make a particular decision?

    Here is my reply concerning data separate from index files:
    See http://www.dizwell.com/prod/node/751 for the complete article.
    "Why wouldn't you keep indexes separate from their tables?! Because doing so makes no difference to performance... and I patiently explained that a table and its index are never accessed simultaneously by a single user so that contention between them cannot arise. And yes, in a multi-user system, of course the two could be accessed simultaneously -but so could two tables, or two indexes. "

  • Using Date Range parameter in Subreport Selection Formula

    I have a subreport which includes this line in the selection formula:
    {Production.Date} = {?Pm-?DateRange}
    {?Pm-?DateRange} appears in the Subreport Links window, so it seems like it should work.
    The DateRange parameter is set by the user in the Main report.
    But the subreport returns no records.
    I tried this:
    In the Main report I created a StartDate and a StopDate field from {?Pm-?DateRange} .
    Then in the subreport selection formula I used these two formula fields like this:
    {Production.Date} >= @StartDate
    and
    {Production.Date} <= @StopDate
    This works!
    So I have found a workaround, but still, I don't understand why the original code {Production.Date} = {?Pm-?DateRange} returns no records.
    Thanks,
    Art

    Hi Art,
    You cannot use a date range parameter directly in the subreport's record selection formula.
    You'll need to create a formula in the Main report like this:
    Minimum(?DateRange) //This gives the start date
    Maximum(?DateRange) //This gives the end date
    Then send these formulas as parameters to subreport for use in the record selection formula.
    I think you've already got this figured out anyway!
    -Abhilash

  • In Security, clicking on the "Saved Password" button displays your current saved password for each site. It does not allow you to change a password. How would you do that?

    In Security, clicking on the "Saved Password" button displays your current saved password for each site. It only allows you to view and delete site passwords. It does not allow you to change a password. How would you do that?

    If you enter a new password Firefox should offer to change the password.
    *You may not need to delete the old password. Try "Refreshing" the page, entering the site again, you may need to let Firefox fill in the old password, then enter the new password, and Firefox should ask to save the new password. See:
    **http://kb.mozillazine.org/Deleting_autocomplete_entries
    *If you delete the old password, you may need to "Refresh" the site after deleting the old password.
    If you want to delete the password that has been saved do the following:
    #In the Tools menu select Options to open the options window
    #Go to the Security panel
    #Click the "Saved Passwords" button to open the passwords manager
    #Select the site in the list, then click Remove
    <br />
    <br />
    '''You need to update the following.''' The Plugin version(s) shown below was/were submitted with your question and is/are out of date. You should update to avoid known security issues with the version(s) you have installed. Click on "More system info..." to the right of your question to see what was included with your question.
    *Adobe PDF Plug-In For Firefox and Netscape 8.3.0 (''Note: this is a very old version and installing the current version may not delete it or overwrite it. To avoid possible problems with having 2 versions installed on your system, you may want to remove the old version in Windows Control Panel > Add or Remove Programs before installing the new version'').
    *Shockwave Flash 10.3 r181 (''this may be current but a new version was released on 2011-06-14 with a ".26" after the "181". You can use the Plugin Check below and/or look in Add-ons > Plugins for the version of Shockwave Flash that you have installed. The newest version will be shown in Add-ons > Plugins as "Shockwave Flash 10.3.181.26"'').
    *Next Generation Java Plug-in 1.6.0_24 for Mozilla browsers
    #'''''Check your plugin versions''''' on either of the following links':
    #*http://www.mozilla.com/en-US/plugincheck/
    #*https://www-trunk.stage.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #*There are plugin specific testing links available from this page:
    #**http://kb.mozillazine.org/Testing_plugins
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**SAVE the installer to your hard drive (save to your Desktop so that you can find it after the download). Exit/Close Firefox. Run the installer you just downloaded.
    #**Use either of the links below:
    #***https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox ''(click on "Installing and updating Adobe Reader")''
    #***''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #**'''''Be sure to <u>un-check the Yahoo Toolbar</u> option during the install if you do not want it installed.
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org/Firefox_:_FAQs_:_Install_Java#Multiple_Java_Console_extensions
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • How would YOU retype these old XM08 types for use in an ABAP OO method?

    The XM08 function group has the following type declarations:
    TYPES: BEGIN OF mmcr_drseg_co.
            INCLUDE STRUCTURE cobl_mrm_d.
    TYPES: cr LIKE drseg_cr    OCCURS 0,
           unpl_refwr TYPE refwr,
           END OF mmcr_drseg_co.
    TYPES: mmcr_tdrseg TYPE mmcr_drseg OCCURS 0,
    TYPES: BEGIN OF mmcr_drseg.
            INCLUDE STRUCTURE drseg.
    TYPES: cr LIKE drseg_cr OCCURS 0,
           co TYPE mmcr_drseg_co OCCURS 0,
           sm LIKE drseg_sm OCCURS 0,
           charact TYPE rbcharact_instance OCCURS 3,
                                           "instances of characteristics
           uebgmat  TYPE matnr,
           uebrblgp TYPE rblgp,
           selkz_db TYPE selkz,
           rblgp_old TYPE rblgp,           "rblgp before aggregation
           END OF mmcr_drseg.
    How would YOU redeclare these types so that they work in an ABAP Objects class?  
    Some of the "fixes" are easy, like replacing "LIKE" with "TYPE:".
    But what about the "INCLUDE STRUCTURE" and the "occurs 0" specifications?
    The reason I'm asking this is that I have to call a method from ZXM08U16 and I'd like to be able to pass this method exactly what XXM08U16 gets from SAP, i.e. the table E_TDRSEG of type  MMCR_TDRSEG

    David,
    I wonder it can be directly in ABAP (I would like to hear opinions from others as well!), I needed to use Data Dictionary as well:
    TYPES: BEGIN OF mmcr_drseg_co.
            INCLUDE STRUCTURE cobl_mrm_d.
    TYPES: cr TYPE z_tt_drseg_cr,
           unpl_refwr TYPE refwr,
           END OF mmcr_drseg_co.
    z_tt_drseg_cr is a table type created in SE11, based on structure drseg_cr.
    the way to create internal table and work area, based on the above:
    DATA : gt_... TYPE TABLE OF mmcr_drseg_co.
    DATA : gw_... TYPE mmcr_drseg_co.
    hope this helps some
    ec
    UPDATE : Rich is right, it is possible to do it only in ABAP with the DEFAULT KEY addition.

  • How do you merge the data of two MIDI regions?

    How do you merge the data of two MIDI regions into one MIDI region without using copy and paste functions in the piano roll editor?

    Sorry - didn't make myself clear. The glue tool would be no good here. I meant that I wanted, for example, to merge the MIDI contents of two regions that are perhaps on different tracks but play back at the same time, i.e. I want to add the 2nd region's MIDI to the 1st region's MIDI, but without having to go into the piano roll editor and cut and paste the data.

  • How would you go about saving an online image locally?

    Say if you knew the url such as http://www.yahoo.com/img.jpg
    How would you save this locally?

    Read the answer in your previous posting:
    http://forum.java.sun.com/thread.jspa?threadID=772451
    Use the file as an InputStream to read the data and then use an OutputStream to write the file.
    The logic is the same as reading and writing a file from disk once you have the InputStream.

Maybe you are looking for

  • Creating and restoring a Boot Camp partition using Paragon

    I am trying to restore a clone of the Boot Camp partition that's on my MacBook Air (Snow Leopard) to My MacBook Pro (Lion). I was told I could do this without requiring the Windows 7 installation disk by using Paragon Hard Disk Manager. I downloaded

  • How do I send an email with a group address and not show the addresses/names of the recipients?

    How do I send an email with a group address and not show the addresses/names of the recipients?

  • Newbie issues

    Hello all, I just started using Final Cut and I would really appreciate some help with a few issues. I am trying to make a demo reel for animation, I have all my animation clips as quicktime files and one .tif image, my problems are: 1. Why is the qu

  • A pcui newbie question

    Hello everybody, I am quiet new to SAP. Now we try to integrate a standard mySAP CRM into a portal over/with PCUI. I down loaded a business package from service marketplace and several inst/admin guides. But to be honest I am not really sure how to a

  • Running a page without showing

    All, is it possible to run a page in the background without showing that page in apex 4.2? i want to run a page process but not to show that page? thanks.