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 |
Dejan
Starting Member
14 Posts |
Posted - 2008-06-22 : 12:41:40
|
I'm using MS SQL Express edition and I have table:ArticleIDSubjectBodyDateThe Date field have data:12.02.200512.02.198912.02.156314.09.134530.12.345I need to show Articles wiich have date today. Example:If today is 12.02.2008 I should show only Date with value 12.02. The results:12.02.200512.02.198912.02.1563independent of year in my dateI try something with DAY, but it's doesn't work.My code:SELECT ArticleID, Subject, Body, Date FROM articlesWHERE Day(getdate())=Left(Date,2) AND Month(getdate())=RIGHT(Left(Date,5),2)I recive error:Msg 245, Level 16, State 1, Line 1Conversion failed when converting the varchar value 'Ju' to data type int. Help :) |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-22 : 12:58:07
|
SELECT ArticleID, Subject, Body, Date FROM articlesWHERE Day(getdate())=DAY(Date) AND Month(getdate())=Month(Date)provided your Date field is of datatype datetime. |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-06-22 : 14:02:17
|
Do you want to use a present index over the "date" column?Try this.select articleid, subject, body, date from articles wheredate like REPLACE(CONVERT(CHAR(5), GETDATE(), 3), '/', '.') + '.%' E 12°55'05.25"N 56°04'39.16" |
 |
|
Dejan
Starting Member
14 Posts |
Posted - 2008-06-22 : 16:03:15
|
Thanks |
 |
|
|
|
|
|
|