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 |
|
mdesai2005
Starting Member
4 Posts |
Posted - 2005-05-11 : 13:50:47
|
I am trying to query a view and receive the following error:"syntax error converting datetime from character screen"after running this query:"select * from viewwhere columnname > '2004-03'"the column is in datetime format (2005-03-26 14:23:56.047)If i run this query:"select * from viewwhere columnname > '2004'"my results come back OKHow can i get the results for just one month? Just one day?Thanks In Advance!-Mook |
|
|
CanadaDBA
583 Posts |
Posted - 2005-05-11 : 14:30:39
|
Use Convert function in your WHERE claus. WHERE SubString(Convert(VarChar(10), ColumnName, 112), 1, 6) >= '200505' The following returns today date in yyyy-mm-dd format.SELECT Convert(VarChar(10), GetDate(), 121) Resutls: 2005-05-10You can find the codes 112 and 121 in BOL under Convert.quote: Originally posted by mdesai2005 I am trying to query a view and receive the following error:"syntax error converting datetime from character screen"after running this query:"select * from viewwhere columnname > '2004-03'"the column is in datetime format (2005-03-26 14:23:56.047)If i run this query:"select * from viewwhere columnname > '2004'"my results come back OKHow can i get the results for just one month? Just one day?Thanks In Advance!-Mook
Canada DBA |
 |
|
|
|
|
|