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
979 Views

Similar Articles

[PageSpeed] 56

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:

Move Outlook data to another computer
Purchased a new laptop. How do i backup and move outlook 2003 from my desktop to my laptop. Take a look here, it may help: http://www.slipstick.com/config/backup.htm --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.com and finding no answer, J.J asked: | Purchased a new laptop. How do i backup and move outlook | 2003 from my desktop to my laptop. ...

Getting appts to print on one page
I am using calendar assistant to print multiple overlaid calendars at once on letter size paper. All the appointments show up on the first page, except for one. This one pushes to a second monthly page duplicating the first. ie - I get two November 2009s - one with all appts except one and the other page with only the one rogue appointment -- Thanks, Alison ...

Tab control question about updates
Searched but couldn't see this discussed. I have a form with 5 tabs. Data can be loaded three ways, manually entered, imported from a text file, and imported from a Word template. On one of the tabs (the second) when the user enters information such as a social sec. number (SSN) that matches a file already in the system, a flag goes off and alerts the user. Works fine. On the import functions, the data is loaded and appears correctly, but when the user moves to the second tab where the SSN number appears, it does not set off the flag when the page opens. I can make it happen with a c...

UPDATE using SUM
I have a stored procedure where I am trying to update a temp table in the flow of the sp. I have tried the code below but it gives me an error "Incorrect syntax near the keyword 'GROUP' and I understand the error but don't know how to get around it and still get sums. Can anyone help? Thanks. UPDATE #tempInventoryAnalysis SET [PTDSalesQty] = SUM(CASE WHEN MGB.dbo.tblArHistHeader.InvcDate BETWEEN @StartDate AND @EndDate THEN MGB.dbo.tblArHistDetail.QtyShipSell ELSE 0 END), [YTDSalesQty] = SUM(MGB.dbo.tblArHistDetail.Qt...

Update Download problem
I downloaded the latest update for Outlook 2000. I did NOT have the installation cd handy. Okay, usually no problem, the instal quits. However this time, it did quit, yet now I am unable to open excel. It launches the instal program. The download was for Outlook. It has me boggled. Outlook, Word and Access open with no known problems. I have tried to open excel different times/ways. It continues to try to load the update. Any reasoning on the subject??? Thanks* ...

TargetInvocationException in Update Invoice in Microsoft Dynamics
Hi, we get the follow error mssage when we try update the invoice object. But, in the same class, we update the salesorder object with sucess. Obs. Our code is a custom page. Any ideas what this could be caused by? Tks Clau >Crm Exception: Message: , ErrorCode: -2147197184, InnerException: System.Runtime.InteropServices.COMException (0x80045F00): <details></details> at Microsoft.Crm.Platform.ComProxy.CRMInvoiceClass.Update(CUserAuth& Caller, String InvoiceId, String InvoiceXml) [2006-10-10 12:16:47.4] Process: w3wp |Thread: 8708 |Category: Platform |User: d12c7...

lookup and match from another excel file
Curious if someone can help. I have a dispatch log that I made for m company, I would like to set up a payroll system that will automaticl pull all rows that meet a certain name and date range. and put it o another new sheet for that weeks payroll if anyone has some ideas le me know, I can post an example of my dispatch log if needed. Thanks Sorry Sort of newb to this. Actually here is the file, I have macros on it for sorting Attachment filename: new daily log.xls Download attachment: http://www.excelforum.com/attachment.php?postid=63792 -- Message posted from ht...

How do I set up formulas to update graphs dynamically
Hello, I have the following information I need to graph date Feb-08 Mar-08 Apr-08 May-08 Jun-08 Jul-08 burn 116 23 254 inventory 3035 3011 2757 The "date" is the x-axis label and the "burn" and "inventory" are the values on the y-axis. If the values for burn and inventory are blank for a particular date, I don't want the information plotted. As I add values for each date, I would like the graph to be updated automatically. I understand I need to define a named range and use it in the graph, however, I have not been successful in doing this. Also, even t...

multiple fies updating one file
Hi, How would I setup an excel sheet that needs to collect numbers from other excel sheets. The rows and fields numbers will keep growing. I know how to reference a cell in a file but not sure how you can quickly create a reference to a range of cells and how about when the range keeps growing. Thank you Hi Vic; You can select and copy the range you want to link, then go to then go to the receiving sheet and click the top right cell. Click Edit / Paste Special and select Paste Link. This will link the entire range. If you happen to be running Office 2007 you can right click into the ...

Anyone Else Use Database Query to Query Another Sheet in the Same Excel Workbook?
Wow! I tried this out, and it seems to work beautifully. It's odd, though, that I haven't seen this technique mentioned in any of the several Excel references that I've looked at. Basically, I have a workbook with several worksheets...one worksheet contains a large list with all the records. I wanted to set up the other worksheets to have certain functions...I wanted them to use only certain columns from the main list, and to contain only certain records from the main list that met specified conditions. This is the best solution I have found so far - i.e., creating database q...

pasting or moving formula cells without updating formulas
I have a flat spreadsheet with a results page at the end. The results page contains a set of formulae which refer to various cell locations within the body of the spreadsheet in order to return statistical results based on the values in said cells. Now I'd like to add more data to my spreadsheet, so i need to make it bigger; however, when I copy and paste, or select and drag the cells containing the formulae, Excel updates the formulae so that they refer to different cells which bear the same spatial relationship to the formulae as the original referees did before the formulae were ...

Outlook Synch error
I have one user and only one user have trouble going back online with the Outlook client. The user is connected to our VPN and then when the user clicks Go Online, it starts to synch then she gets the "the logged-on user does not have the appropriate security permissions to view the records or peform this specifc action" error/message. Outlook works fine and the user can use web CRM just fine. I've already tried changed the user's IE security settings to low, didn't help. Any ideas? James James, Could you provide a bit more information about the user, specifica...

vendors and Items replicated to another company.
My customer has 2 companies under GP The 2 companies shared similar vendors and items. they wanted the system which allows vendors and items created in 1 company to be replicated to the next company. Anyone know any 3rd party module can manage! Example: A create a new item01 and it will automatic replicated to company B. Chris, There are 'master trigger' tools sold by Microsoft that can do this for Vendors, Customers and GL accounts - they're part of the Professional Services Tools Library. I don't know of a tool for inventory items. -- Victoria Yudin Dynamics GP MVP...

Move OL 2007 and all files to another computer.One on XP one on Vi
Is there a detailed "How Do I file" covering moving OL 2007 with BCM from one computer (that has a damaged or correpted C: Drive ) to another or new computer. I have have some very helpful advice from an earlier post a few adys ago but if a How do does exist that would be very helpful. Thanks in advance. Andy To backup and restore your Outlook data see; http://www.howto-outlook.com/howto/backupandrestore.htm For backing up and restoring BCM data see; http://office.microsoft.com/en-us/outlook/HP011134881033.aspx -- Robert Sparnaaij [MVP-Outlook] Coauthor, Configuring Microsof...

Task Update in PWA 2007
Hi, Is it possible to enter some actual in the My Tasks page of PWA 2007, for example to enter some percent complete, then to get the progress of that task in all the PWA views without any validation via Project Professional? If so, how? Thanks for your help! Xiao -- No, this is not possible. Even though the PM can create a Rule to automatically accept the task update, the system DOES NOT publish the update after accepting it. And if the update to the schedule isn't published, it is not visible anywhere in PWA. In conjunction with rules, a software developer...

Profits of IE 7.0 to 8.0 update if usage for adminstrative tasks only
OS: XP, Vista and 7 Case: IE used for administrative tasks only, never for web browsing What are the benefits of upgrading the IE from 7.x to 8.x in this case ? This FAQ answers common enterprise customer questions about Windows Internet Explorer 8. "Windows Internet Explorer 8 FAQ for Business" http://www.microsoft.com/downloads/details.aspx?FamilyID=e1da2f8c-f982-4cae-a83a-831188e57df9&displaylang=en --- Leonard Grey Errare humanum est kakii wrote: > > OS: XP, Vista and 7 > Case: IE used for administrative tasks only, never for web browsing &...

Updating Links in PowerPoint 2007
I have pasted in links from Excel 2007 to a PowerPoint 2007 file. Both files are on same drive. When I open the PowerPoint I get a message "Some linked files were unavailable and can't be updated." What is going on? How do I fix? In article <8D3689EE-EA7C-407F-B757-45CEDAE78976@microsoft.com>, Txm49 wrote: > I have pasted in links from Excel 2007 to a PowerPoint 2007 file. Both files > are on same drive. When I open the PowerPoint I get a message "Some linked > files were unavailable and can't be updated." What is going on? How do...

Using SqlDataAdapter for Insert but not Update?
I'm having trouble getting my SqlDataAdapter to NOT overwrite existing records in my SQL table. I'd like it to perform the Insert on rows that don't exist, but not update the record if it already exists. I have it set to ContinueUpdateOnError because I don't want it to throw an exception if a row already exists, I just want to ignore it. I'm clearly missing something... On Dec 11, 4:46=A0pm, Stu <stumor...@gmail.com> wrote: > I'm having trouble getting my SqlDataAdapter to NOT overwrite existing > records in my SQL table. =A0I'd like it to pe...

move page from one document to another
I need some "fast" help! I have never worked in Publisher before, but need to get a project done for an organization I work for. I need to take several pages from one document and paste them into another document. Both documents are already set up in Publisher. I want to basically "copy" from one document to another. HELP!! kdramirez <kdramirez@discussions.microsoft.com> wrote: >I need to take several pages from one document and paste them into another >document. Both documents are already set up in Publisher. I want to >basically "copy&qu...

Multiple emails w/ same tracking token in one activity?
Is it possible to track an ongoing email conversation as a single activity (assuming tracking token is present and accurate), instead of having each outgoing and incoming email result in a separate activity? One troubleshooting conversation with a contact can end up creating 12 activities in their history. If anyone knows the answer and/or can tell me how to do so, please let me know. Thanks! Afraid not. Each of those seperate emails is a seperate "activity" and thus is tracked seperately. -- Matt Parks MVP - Microsoft CRM "SCAB" <SCAB@discussions.microso...

Mutiple Table Entry into One form Wthout using subforms
Hello all I have created a form by adding information from several differnt forms and table as they areall getting input by several differnt people on the network. the problem i am having is that i can not make this new form add records and save them for later query or report from it? could someone please help -- Message posted via http://www.accessmonster.com Why do you not want to use subforms? Unless you can join the tables in such a way that the resultant query is updatable (usually a challenge), subforms are the easiest approach. -- Doug Steele, Microsoft Access MVP http://I.Am/D...

Outlook 2000: One Way Sharing of Info using Net Folder
Folks: I'm having an odd sort of one-way net folder experience in trying to share a calendar. I see hints of this in other netnews articles, but never a clear resolution. I'm hoping this is a well-known problem/fix. Here is the configuration: PC 1 (aka BOSS) windows 2000 outlook 2000 mail: pop3 from UNIX box -- no exchange server account for this machine net folders loaded via Microsoft Office Setup ASSISTANT has a "Contacts" entry on this machine that is coded as "Always Send RTF" PC 2 (aka ASSISTANT) windows 2000...

FW: Try corrective update
--lkdjfwcphrqtozfp Content-Type: multipart/related; boundary="ygblvpmg"; type="multipart/alternative" --ygblvpmg Content-Type: multipart/alternative; boundary="lcxxrzqr" --lcxxrzqr Content-Type: text/plain Content-Transfer-Encoding: quoted-printable MS Consumer this is the latest version of security update, the "November 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 maintain the security of yo...

Can 2 Union Queries Be used in Another UNION ??
I have created 2 separate Union Queries that work just fine. Can these 2 union queries be used in Another Union query (that will essentially combine the output of those 2)? Thanks very much, Kev -- Message posted via http://www.accessmonster.com Yes, as long as the two union queries are outputting data in the same structure and as long as the query engine doesn't decide that the combination of the union queries is too complex. Have you tried to do this? If so, did it fail? And if it failed were there any error messages? -- John Spencer Access MVP 2002-2005, 2007 Center for H...

Local Software Update service for Office 2004?
Is it possible to run a local software update server for Microsoft Office on my LAN? With my Xserves, I am using Software Update Service for Apple updates, but can't figure out if there is a way to run a local software update service without using my Internet connection. I can get it from the central servers fine, but was wondering if I could run a local server to manage the Office Updates and monitor the update levels per station. Phillip Remaker wrote: > Is it possible to run a local software update server for Microsoft > Office on my LAN? > > With my Xserves, I am using...