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 : 01:40:58
|
| hi friends,i got the problem in the stored procedurei have fields like date and quantityfor the current year i have quantitybut at the same time i want to display the quantity depending on the previous yearplease give me the solutionregards,vijay |
|
|
lightsql
Starting Member
17 Posts |
Posted - 2009-06-02 : 02:01:40
|
| I don't know if i got you're problem right but you can include a WHERE clause on your select statement in coordination with BETWEEN.Ex:DECLARE @startdate datetimeDECLARE @enddate datetimeSET @startdate = '01/01/2009'SET @enddate = CAST(Now() AS datetime) --This is to get the current date though you can probably omit the CAST functionSELECT * FROM TABLESample WHERE Col_Date BETWEEN @startdate AND @enddate |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-02 : 02:07:49
|
quote: Originally posted by lightsql I don't know if i got you're problem right but you can include a WHERE clause on your select statement in coordination with BETWEEN.Ex:DECLARE @startdate datetimeDECLARE @enddate datetimeSET @startdate = '01/01/2009'SET @enddate = CAST(Now() AS datetime) --This is to get the current date though you can probably omit the CAST functionSELECT * FROM TABLESample WHERE Col_Date BETWEEN @startdate AND @enddate
I think NOW() is known in MySQL but not in SQL Server.GETDATE() should work. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-06-02 : 02:13:27
|
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=126864 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
lightsql
Starting Member
17 Posts |
Posted - 2009-06-02 : 02:16:31
|
| Thanks for the correction, that is correct webfred, hehehe |
 |
|
|
|
|
|