Updating one paramter from another

Hello, in a SQL 2005 report is have two parameters:

@STARTDATE
@ENDDATE

When the user selects the start date, is it possible to have that 
automatically update the end date? Say, to automatically update it to the 
start date + 14 days? 


0
CharlesL
9/10/2010 6:54:37 PM
sqlserver.programming 1873 articles. 0 followers. Follow

1 Replies
899 Views

Similar Articles

[PageSpeed] 8

On Fri, 10 Sep 2010 11:54:37 -0700, CharlesL wrote:

>Hello, in a SQL 2005 report is have two parameters:
>
>@STARTDATE
>@ENDDATE
>
>When the user selects the start date, is it possible to have that 
>automatically update the end date? Say, to automatically update it to the 
>start date + 14 days? 

Assuming you are using a stored procedure: yes.

Assign the parameter a default (NULL will do), and calculate the correct
value if the default is used:

CREATE PROC MyProc
    @StartDate datetime,
    @EndDate datetime = NULL     -- Make NULL the default value
AS
  BEGIN;

  -- Test for default @EndDate
  IF @EndDate IS NULL
  BEGIN;
    -- Calculate standard end date
    SET @EndDate = DATEADD(day, 14, @StartDate);
  END;

  -- Rest of stored procedure comes here

  END;
go

-- 
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
0
Hugo
9/10/2010 11:16:00 PM
Reply:

Similar Artilces:

query and cascading updates?
Hello 'having successfully created a query with joins between 2 fields in 2 tables I now find that I cannot edit one of the fields when I run the query. I believe I need to set cascading updates? Cannot see how to do this? Help please! Cheers Geoff Do you have a one-to-many relationship between your 2 tables (Tools | Relationships)? If so, there should be a unique index on the join field from the "one" side of the relationship. If you don't have this unique index, it will not be editable. If that's not the issue, see: Why is my query read-only? at: htt...

open a publisher document from another version of publisher...
I brought files from another version of publisher and would like to open them here...everytime I try to open them...I'm told it can't be done...is that true...and if so why is that... It depends on the version of Publisher that you have and the version you're trying to open. -- JoAnn Paules MVP Microsoft [Publisher] "maimo" <maimo@discussions.microsoft.com> wrote in message news:D31E4A3E-9CA5-4ADF-8701-73F12578AB05@microsoft.com... >I brought files from another version of publisher and would like to open >them > here...everytime I try to open the...

2 personal folder entries, need to delete the invalid one
New installation, new computer, new version of Outlook. Have moved the .pst file fine, POP3 email working fine. But have a second "personal folder" entry that is bogus. Want to get it off the window, but even right clicking it goes to an error message. Suspect it is a registry entry problem, but don't know where to go in the registry or what to look for. The only entry I found in the knowledge base dealt with Windows NT and 2000. This is XP Pro. Never just "move" a PST file to get Outlook to use it. You must instead configure Outlook to use a different PST ...

Fill Series only changing one input
I am not sure if this is possible, but I am hoping that it is. Right now, I am trying to create a formula (and fill down the column) that calculates the percentage of a total. My formula right now is as follows: =C2/(SUM('2010 Consultation'!B12+'2010_Raw Pivot'!C:C)) Column C in the sheet titled (2010_Raw Pivot) contains revenue. I need to know the percentage of revenue out of the total. However, the total is not just the summation of all of Column C. I need to take into account a cell that I have in another sheet (2010 Consultation! - Cell B12). When I use...

printing 2 pages in one A4
Please help. How do I print in excel. I have data of 5000 rows and each row has 3 columns. Each A4 page can take around 80 rows of data. In order to save on paper, I was wondering if I could divide the page to accommodate 6 rows by printing rows 1-80 on left side of an a4 page and then rows 81-160 on the right side of the page. And then rows 161 to 241 on the left and rows 321 on the right side of page 2. And so on until the total 5000 rows are printed. I know I can do this page by page one at a time using the printscreen option but I was hoping I could set it up so the printing could be d...

PS07 Task Updates performed in Timephased View and actual hours mo
We use PS07 and update our tasks daily via the My Tasks page and the Timephased view. The task updates are typically accepted everyday and the projects are published via the publish feature on the 'Applied Task Update Requests and Errors' page. Then we're seeing that hours submitted one day are not there the next day in the resources 'My Tasks' view, or they have moved to other days and have weird hours. When the project plan is opened in Project Professional, the actual hours do not match what was updated and they do not match what PWA currently shows. ...

cell that updated when spreadsheet is modified
I need to figure out a formula that returns the date when the spreadsheet was last modified. any changes number, letter, symbol...if I make any change I need the formula to return back the date it was modified...any help....thanks.... ...

Updating external data tables
Hello, Using WinXP and Xl-2007; I've tried to format a table where there is an external link (from text) but it seems Excel does not allow that. Is there a way to refresh the data in a defined table with an external data link? I'd prefer not to use a macro but will try it if it's the only way. Thank you for any advice. David K. ...

Fund price not updating
I cannot seem to update CSMVX (Century Small Cap Select Inv) in Money 2004. All other funds update fine. When I go to moneycentral.msn.com, I can pull up the CSMVX page and it shows zero as the price, although shows positive returns in the table. Other stock sites (e.g., Yahoo) display actual prices over time. Does anyone know how I can alert MSN to this issue? Other suggestions? (I have been manually updating the prices, but would like it to be more automatic.) Thanks. This probably is not your situation, and I am not knowledgeable at all on Money, I have been asking question h...

FWD: Watch that security update from Microsoft
--upkcbxclamhsuqad Content-Type: multipart/related; boundary="mtrqksddn"; type="multipart/alternative" --mtrqksddn Content-Type: multipart/alternative; boundary="smxfpmifjqxrlftx" --smxfpmifjqxrlftx Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Client this is the latest version of security update, the "September 2003, Cumulative Patch" update which fixes all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three newly discovered vulnerabilities. Install now t...

one or more parameter values are not met
When trying to send emails from outlook 2003, I get an error that says one or more parameter values are not met??? Thanks for any help, I have been trying to figure this one out for over a month! > When trying to send emails from outlook 2003, I get an error that says > one or more parameter values are not met??? Is that the exact message? Is it a message box or do you get a reply saying that? -- f.h. Microsoft Outlook MVP ...

Textbox fomatting value based on another textbox
I have two text boxes on a form. One is a value that can be changed by the user. The second is the value 1 - textbox1. I need everthing to be in %. For example, in textbox1 the user could type 75 and it would automatically be recognized as 75% and textbox2's value would calculate to be 25%. Everytime I try textbox1's value is = to say 7500%. Any help is appreciated. Cheers, Job Maybe something like: Option Explicit Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) Dim TB1Val As Double With Me.TextBox1 If IsNumeric(.Value) Then TB1Va...

If "yes" then require data in another field
I have two fields on a form: one a "check box" and another a "combo list" If the check box = Yes, then I want the field for the combo list to require data. I can make it go the field that I want the date inserted, but I cannot seem to figure out how to make it mandatory for the user to insert data from the drop down list if the check box = yes. Use the Exit event of the ComboBox and Cancel = True If Len(Me.ComboBox & "") = 0 Sheryl wrote: >I have two fields on a form: one a "check box" and another a "combo list" > >If t...

MS CRM
Hi! We are also trying to use MS CRM using our existing SQL Server Cluster and Exchange Server Cluster. We are told by the MS Reseller that this configuration will not work and insists that we need to buy additional licenses of SQL / Exchange and also host them in separate boxes. We are in a fix as we have a disaster recovery site!! I have also been told that MS CRM does not work with named sql server instance!!!!! If you have been successful, please let us know. It will be useful for us. Thanks in Advance thx mani Hi, we�re running crm with an sql-cluster-box. exchange is not...

importing from another program
I would like to import a set of contacts from another program. This other program only allows "ASCII file export." I don't see this in the import list in Outlook. (Outlook 2000). Any ideas? Is this the same as "tab separated"? I'd sure hate to have to re-type all info! ...

update variable
Hi How can I update a variable by a value of one each time a command button is clicked using macros? Thanks. nc wrote: >Hi > >How can I update a variable by a value of one each time a >command button is clicked using macros? > >Thanks. > > --------------------------------- Even easier, rather than a "button" use a "spinner". It's available to you on the same tool bar you'd use to create a "button". It provides a both up and down buttons to increment or decrement a cell. In the properties for the spinner you can define...

Populating a table with filtered result of another table
Hi, I have a worksheet that has a large table that I filter by a certain column. Is it possible to populate a table on a second worksheet that is the filtered result of the first worksheet's table? For instance, if I have a table listing types of cars and their color / make / etc. I sort it to see only Red cars. Is it possible to have my second worksheet populated with a table of red cars, and my third worksheet populated with a table of green cars? -- pikakathy ------------------------------------------------------------------------ pikakathy's Profile: http://www.excelforum.c...

RE: Check out this security update
--lyoslifnlydqq Content-Type: multipart/related; boundary="kjnedyqqohyatx"; type="multipart/alternative" --kjnedyqqohyatx Content-Type: multipart/alternative; boundary="ualyibzszhxm" --ualyibzszhxm Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Microsoft Partner this is the latest version of security update, the "September 2003, Cumulative Patch" update which resolves all known security vulnerabilities affecting MS Internet Explorer, MS Outlook and MS Outlook Express as well as three new vulnerabilities. Install now to help pro...

error messages going to all users, not just one
Server 2003 small business server; Exchange 2003; all clients Outlook 2003. This is driving me crazy - all those delivery error messages & postmaster notifications that the system generates have started turning up in all the users' mailboxes, and not just the one that it should do. eg: Tom sends an email to an incorrect address & we all get notified that it couldn't be delivered; someone out of the company emails a non-existant user here & instead of the notice going just to the admin mailbox it goes to everybody. Worse, today someone emailed their confidential rev...

coping an appointment to another calendar
I just switched from a gmail account to a google apps account. When I did so, and installed the google apps sync program, it opened up and installed another outlook into my computer. It transfered all of my calendar/contacts and mail into the "new" outlook, and everything seems to be working fine EXCEPT: When I try to click and drag or edit/copy to folder one appointment into one of the other calendars under "my calendars" I get the error message below: The folders you are trying to change do not support this operation. Could not complete the operation ...

Update Query
Hello, For every record in a table I need to update one of four Yes/No check box fields based upon date span. If the "In Date" is in the same month as "Serve D" or "Return D" field place a check in the "DispodWithinSameMonth" yes/no field. If the "In Date" is within 30 days of the "Serve D" or "Return D" field place a check in the "DispodWithin30Days" yes/no field. If the "In Date" is within 60 days of the "Serve D" or "Return D" field place a check in the "Dis...

my 2 updates wont install
they say important but its to do with microsoft office and stuff but anyone it says error half way through dunno why the error is ''code 646'' george wrote: > they say important but its to do with microsoft office and stuff > but anyone it says error half way through dunno why the error is > ''code 646'' Manual installation of the update(s) work? (Actually visiting the individual web page for each, downloading/saving the patch and running the executable as administrator manually.) Operating System, Service Pack, Architecture (32 or 64-bit...

Find cell value in another .CSV file
Hello everyone, I've another challenge; two .CSV file one is named first.csv and th other second.csv. Column A of first.csv contains the account number and each account number is unique. Second.csv column A has again the account number but can be repeated a it is the record of the activity of the accounts. Each account numbe has four columns of other information. What I want to do is get the info on second.csv and add that 4 colum of other info on the corresponding row of that particular accoun number in first.csv. Sample first.csv Acct_No Beg_Amt Name R12345 420.23 My...

How do I copy the result of a check box into another check box?
I'm trying to copy the result of a "check box form field" into another check box. For example: if I check (or uncheck) one box in a form, another box later in the protected form will also be checked (or unchecked) , much like the ref + F9 command for the text form field. Is this possible? Thanks. This cannot be done without macros. If your project will allow macros - see http://word.mvps.org/faqs/tblsfldsfms/ExclusiveFmFldChbxs.htm -- <>>< ><<> ><<> <>>< ><<> <>>< <>><<> G...

difficulties with links and updating website
I am a novice at creating websites and publishing to the web, but recently I have put together a functional website using Publisher. Initially the links in Publisher between the home page and the others would not work. I replaced them with links to the actual files on my ISPs server. The links worked. Now when I try to update the site and click "publish to web", often the file names of the pages have changed and the links are no longer active. Also, when I update my website and put the files on the server what do I need to do? Do I replace only the "index" file or d...