Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 6th, 2006, 05:17 PM
Registered User
 
Join Date: Aug 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stored Procedure Help.

Hi there,

I have been trying to build this stored procedure but no luck so far. this is what I'm trying to accomplish;

a stored procedure to pull sales from let's say sales from a specific date 10/10/06 and I want the same stored procedure to pull sales data from one year before 10/10/05 from the first parameter.

so I want the stored procedure to pull data from one date and one year's date before.

Thanks for your help.

Midway.



 
Old November 14th, 2006, 07:31 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Post your attempt at the stored procedure your trying for.


 
Old November 20th, 2006, 06:34 AM
Authorized User
 
Join Date: Aug 2006
Location: Pune, Maharastra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

use this

select OrderDate, dateadd(yy,-1,OrderDate) from Orders

 
Old November 20th, 2006, 06:36 AM
Authorized User
 
Join Date: Aug 2006
Location: Pune, Maharastra, India.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

select * from orders
where orderdate between 'date you want to start' and datediff(yy,-1,date from you want to minus 1 year)

all the best





Similar Threads
Thread Thread Starter Forum Replies Last Post
stored procedure prashant_telkar SQL Server 2000 1 July 9th, 2007 07:57 AM
Stored Procedure jezywrap SQL Server ASP 1 January 3rd, 2007 12:29 AM
stored procedure kdm260 SQL Server 2000 2 June 19th, 2006 04:45 PM
Stored Procedure rajanikrishna SQL Server 2000 0 July 18th, 2005 05:01 AM
Help About Stored Procedure zhuge6 BOOK: ASP.NET Website Programming Problem-Design-Solution 3 May 20th, 2005 09:27 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.