• drew.allen (7/6/2015)


    You were actually very close. The problem is here.

    order by ABS (DateAdd(Minute, 30 * (DateDiff(Minute, 0, closedate) / 30), 0)) ASC

    DATEADD() returns a date/time and ABS() takes a float, and it can't implicitly convert a datetime to a float.

    The other thing I would suggest is that instead of this:

    and day (close_date) = '03'

    and month(close_date) = '08'

    and year (close_date) = '2014'

    you try this:

    and CAST(close_date AS DATE) = '2014-08-03'

    Drew

    You really should avoid all functions on columns whenever possible. Thus, here's the preferred method:

    (close_date >= '20140803' and close_date < '20140804')

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".