• Webrunner,

    select @startDt = getdate()

    select @startDt =

    dateadd(millisecond,0-datepart(millisecond,@startDt),

    dateadd(second,0-datepart(second,@startDt),

    dateadd(minute, 30-datepart(minute,@startDt),

    dateadd(hour,10-datepart(hour,@startDt),

    @startDt))))

    So the idea is that you can start with any date time and set it to a specific time.

    If you want the time to be 10:30, then you need to figure out what the current hour and minutes are and set them to 10:30. A way this can be done is to take the hour you want and subtrack it from the current hour. So if the current hour is 8, then 10-8 is 2, you add 2 to 8 and get 10, which is what you want.

    The second and millisecond part is just to remove the seconds and milliseconds from the current datetime.

    It also causes more confusion unless you figure out what it is doing.

    Anyway, I don't know if that helped explain it any better. There are certainly better ways to set a datetime to a specific time, but this way served its purpose of distracting the reading, so they wouldn't notice the real problem is dividing by 60 instead of 60.0

    Ben