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 |
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2011-04-25 : 19:42:45
|
| Hi All,I have a table which has 6 columns, out of which last 2 are start date and end date. As part of my stored procedure, I have written a select statement that will fetch me all the parameters of the table. I also want to check if the current date falls between the 'Start Date' and 'End Date' column values and return true if it does else return false. Can anyone please tell me how can I achieve this in the same stored procedure?Thanks in anticipation,Mavericky |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2011-04-25 : 20:05:50
|
[code]SELECT . . . .case when start_date <= dateadd(day, datediff(day, 0, getdate()), 0) and end_date >= dateadd(day, datediff(day, 0, getdate()), 0) then 'TRUE' else 'FALSE' endFROM yourtable[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Haz.vali
Starting Member
3 Posts |
Posted - 2011-04-26 : 02:00:54
|
| CREATE PROCEDURE Productasbeginselect * , case when getdate() between S_date and End_date then 'TRUE' else 'FALSE' end as DATE_MATCH from dbo.Product_Sales end |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2011-04-26 : 11:26:53
|
| Thanks a lot everyone!!! Your solutions worked.My problem is solved.Mavericky |
 |
|
|
|
|
|
|
|