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 |
|
AKP2008
Starting Member
45 Posts |
Posted - 2008-12-03 : 01:49:29
|
| Hi,When i execute the below statements i am not getting the result.DECLARE @MonthDate DATETIMESELECT @MonthDate = '01/31/2009'SELECT * FROM TABLENAME WHERE CONVERT(VARCHAR(16), Startdate, 101) <= CONVERT(VARCHAR(16), @MonthDate, 101)In my table All startdates are less than '01/31/2009'.Please help.Thanks in Advance. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-03 : 02:06:27
|
what about this?DECLARE @MonthDate DATETIMESELECT @MonthDate = '01/31/2009'SELECT * FROM TABLENAME WHERE Startdate <= @MonthDate |
 |
|
|
AKP2008
Starting Member
45 Posts |
Posted - 2008-12-03 : 03:51:28
|
quote: Originally posted by visakh16 what about this?DECLARE @MonthDate DATETIMESELECT @MonthDate = '01/31/2009'SELECT * FROM TABLENAME WHERE Startdate <= @MonthDate
It works perfectly.Thanks for the solution. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-03 : 03:57:31
|
Now take time to LEARN why it worked.A hint is "string sorting". E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|