Error!
Success!

DateTime.Round

0
kicks

DateTime.Round  (Unpublished)

I recently needed to group by minutes (or seconds, or hours, or days) in a LINQ to SQL expression, and I found that there isn’t a round function built into the C# DateTime object. The following will round to the nearest second, minute, hour, or day. I stopped there because different months have different numbers of days (and I don’t need to group by months…) but it is easy enough to add months and years to the code.


Kicked By:
Drop Kicked By: