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 |
|
jayram11
Yak Posting Veteran
97 Posts |
Posted - 2010-09-24 : 16:05:53
|
| Hii have a table with code, from(date) and thru(date) columns. i need a query for the followingWhen i pass a code and date on the front end i want to check if the date i passed is less than from column, if it is, i should retrieve from date if it is not and the thru date is NULL, i should just return thru date which would be null. if the thru date is not NULL and the date i passed is greater than from date, i have to check to see if the date i passed is between from and thruHelp!!!Thanks |
|
|
sathiesh2005
Yak Posting Veteran
85 Posts |
Posted - 2010-09-25 : 06:37:12
|
| if @your_date < FRMDate and TRUDate is not null thenReturn (select FRMDate from <your table>)elseif @your_date > FRMDate and (TRUDate is not null and @your_date < TRUDate ) then print "your date is in between"else return null end if@Sathiesh |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-25 : 07:27:16
|
quote: Originally posted by sathiesh2005 if @your_date < FRMDate and TRUDate is not null thenReturn (select FRMDate from <your table>)elseif @your_date > FRMDate and (TRUDate is not null and @your_date < TRUDate ) then print "your date is in between"else return null end if@Sathiesh
What kind of Transact-SQL is that? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-09-25 : 07:28:04
|
quote: Originally posted by jayram11 Hii have a table with code, from(date) and thru(date) columns. i need a query for the followingWhen i pass a code and date on the front end i want to check if the date i passed is less than from column, if it is, i should retrieve from date if it is not and the thru date is NULL, i should just return thru date which would be null. if the thru date is not NULL and the date i passed is greater than from date, i have to check to see if the date i passed is between from and thruHelp!!!Thanks
We could give a better help if you would provide sample data and wanted output. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|