It looks like you have a missing paren in the statement cast('2005'
as char(4)) as datetime)
try cast(('2005' as char(4)) as datetime)
On Sun, 6 Mar 2005 15:15:20 +1100, Michael Kear <[EMAIL PROTECTED]> wrote:
> I've been using this query for ages, until the end of last year when it
> started throwing errors. I got around it by hard-coding some of the parts
> of it, and now I'm getting back to trying to fix it. Can anyone see
> what's wrong with it?
>
> SELECT annivID,Event,Day,Month,Year,name,comments
> FROM anniversaries
> WHERE DATEPART(wk,cast(rtrim(cast(Month as char(2)))+'/'+rtrim(cast(Day as
> char(2)))+'/'+cast('2005' as char(4)) as datetime))= DATEPART(wk,getdate())
> order by month, day
>
> The error it gives is:
> Server: Msg 242, Level 16, State 3, Line 1
> The conversion of a char data type to a datetime data type resulted in an
> out-of-range datetime value.
>
> What it's supposed to do is produce a list of anniversaries where the month
> and date are between Sunday of this week and Sunday of next week, without
> regard to the year. It's a list of celebrity birthdays.
>
> Cheers
> Mike Kear
> Windsor, NSW, Australia
> Webmaster, Bluegrass Australia
> http://bluegrass.org.au
> -----------------------------------------------------
> Not a preacher, not an expert but a fan
> - speaking from the heart.
> Talking dog on http://Bluegrasscountry.org
> -----------------------------------------------------
> We are a Bluegrass Unlimited Reporting Program
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2201
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54