Thursday, October 30, 2014

Skip minutes from date and time field

Is that what you are looking for?



DECLARE @Dt AS DATETIME;
SET @Dt = '2014-10-16 12:10:00.000'
SELECT CONVERT(VARCHAR(16), @Dt, 120);



If this is only for display purpose the application code can handle this. If your using this in a SQL query for filtering then native datetime data type is recommended for performance.


You can read more on below articles:


What is the most efficient way to trim time from datetime? - Aaron Bertrand


Bad habits to kick : mis-handling date / range queries - Aaron Bertrand




Krishnakumar S


No comments:

Post a Comment