• A useful script, that is nearly there, but not quite.

    select dbo.dateceiling('2010-11-29 18:00:00.000','hh')

    should return 2010-11-29 18:00:00.000 in the same way that select ceiling(1.00) returns 1

    However, it doesn't - it returns 2010-11-29 19:00:00.000

    Looking at the code, the same would be true for minutes & seconds where the rest of the datetime was zero.

    A small, but potentially important, bug.