With SQL Server 2008 the time data type has an optional precision argument (default is 7). With this you can control how many fractional decimal places are stored and displayed.
DECLARE @time time(3)
SET @time = GETDATE()
PRINT @time
The above would print this,
10:47:25.347
The documentation says the smallest precision is time(0). This would store and print 10:47:25.
Is it possible to reduce the precision even more, to eliminate/zero out seconds: 10:47?
I know this can be done manually by adding a constraint (DATEPART(seconds, @time) = 0), performing math on data entry to zero out the seconds, and manually format when printing, but I am looking for a simplier way to just define a field in a table as “hours and minutes”, in much the same way that the date type allows you to define a field as “just the date, no time component”.
No. It is not possible to reduce the precision of the
timedatatype any further thantime(0)