Scenario: A stored procedure receives from code a DateTime with, let’s say DateTime.Now value, as a datetime parameter. The stored procedure needs to store only the date part of the datetime on the row, but preserving all date related arithmetics for, to say, do searches over time intervals and doing reports based on dates.
I know there is a couple of ways, but what is the better having in mind performance and wasted space?
Business Logic should be handled outside of the proc. The procs jobs should be to save the data passed to it. If the requirment is to only store Date and not time, then the BL/DL should pass in DateTime.Now**.Date** (or the equiv…basically the Date part of your DateTime object).
If you can’t control the code for some reason, there’s always convert(varchar(10), @YOURDATETIME, 101)