I have an sql DateTime (ms sql server) and want to extract the same date without the seconds: e.g. 2011-11-22 12:14:58.000 to become: 2011-11
DateTime
2011-11-22 12:14:58.000
2011-11
To Round Off it:
DECLARE @TheDate DATETIME; SET @TheDate = '2019-1-2 12:14:58.400'; SELECT CAST(@TheDate AS SMALLDATETIME);
To just Truncate:
DECLARE @TruncTheDate DATETIME; SET @TruncTheDate = '2019-1-2 12:14:58.400'; SELECT DATEADD(mi, DATEDIFF(mi, 0, @TruncTheDate), 0);