In SQL Server, how do I "floor" a DATETIME to the second/minute/hour/day/year?
Let's say that I have a date of 2008-09-17 12:56:53.430, then the output of flooring should be:
- Year: 2008-01-01 00:00:00.000
- Month: 2008-09-01 00:00:00.000
- Day: 2008-09-17 00:00:00.000
- Hour: 2008-09-17 12:00:00.000
- Minute: 2008-09-17 12:56:00.000
- Second: 2008-09-17 12:56:53.000
And yes, I fully intend on answering my own question in about 30 seconds. I don't think there's any SO etiquette against that.