List/Grid

Tag Archives: Datetime

Removing minute/second/milisecond from the Datetime – SQL Server

To remove minute, second, milisecond part from the date we can either do SELECT CONVERT(DATETIME, CONVERT(VARCHAR(13), GETDATE(), 127) + ‘:00:00.000′) OR SELECT DATEADD(MILLISECOND,(0-DATEPART(MILLISECOND,GETDATE())), DATEADD(SECOND,(0-DATEPART(SECOND,GETDATE())), DATEADD(MINUTE,(0-DATEPART(MINUTE,GETDATE())),GETDATE()))) In first case, first we… Read more »

Convert string to datetime – SQL Server

Easiest way to convert the string into datetime, without worrying about the language settings in sql server is to use ’1-Jan-2010′ pattern. DECLARE @Day INT = 2 DECLARE @Month INT… Read more »