I was writing some SQL Server code to strip the time portion off a date/time value - it took me about half an hour to find a way of doing it that didn't kill performance (as I needed the calculation doing in the where clause of a select statement). The code I came up with was:
declare @DateAndTime datetime
declare @DateOnly datetime
select @DateAndTime = getdate()
select @DateOnly = cast(floor(cast(@DateAndTime as float)) as datetime)
select @DateAndTime as DateAndTime, @DateOnly as DateOnly
Half an hour for something that ought to be really simple. It made me think that date/time handling is pretty poor in nearly all languages.
Which is why the best thing that DHH ever did (if it wasn't him, my apologies to the author) was:
Not quite solving the problem described above but absolute genius and the way dates and times should work.
The next version of our application is going to have a denormalised date only field that is populated on a trigger. Ugly but better than the where clause hack shown above.
What's better than
10 minutes ago.