Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
vijayanto
Starting Member
16 Posts |
Posted - 2009-06-02 : 00:29:44
|
| hi friends,i got the problem in the stored procedurei have fields like date and quantity for the current date i have quantity but at the same time i want to display the quantity depending on the previous date please give me the solutionregards, vijay |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-02 : 00:33:08
|
Homework?SELECT SUM(Quantity)FROM Table1WHERE Date >= DATEDIFF(DAY, 1, GETDATE())AND Date < DATEDIFF(DAY, 0, GETDATE()) E 12°55'05.63"N 56°04'39.26" |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-06-02 : 00:34:04
|
| will u update ur table structure and expected output?Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceled |
 |
|
|
vijayanto
Starting Member
16 Posts |
Posted - 2009-06-02 : 00:49:30
|
| Thanks |
 |
|
|
SQLRatankalwa
Starting Member
42 Posts |
Posted - 2009-06-02 : 02:57:25
|
| You Can also do itSELECT SUM(Quantity)FROM Table1WHERE Date Between Getdate() -1 AND GetDate()using the above method.Ratan KalwaSQL Server Professionals User Grouphttp://www.revalsys.com |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-02 : 02:59:50
|
quote: Originally posted by SQLRatankalwa SELECT SUM(Quantity)FROM Table1WHERE Date Between Getdate() -1 AND GetDate()
Also if there is time information in the Date column? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|