Transact-SQL: How to get current date with start time 00:00:00 and end time 23:59:59
--SQL Server stores milliseconds with a precision of 1/300ths of a second.
-- So in other words, milliseconds are stored as:
--.000
--.003
--.007
--.010
--.013
--.017
-- etc.
SET DATEFIRST 1
SET DATEFORMAT ymd
SELECT
DATEADD(ms, 0, CONVERT(varchar(10), GETDATE(), 120)) as 'StartToday'
,DATEADD(ms, -3, CONVERT(varchar(10), GETDATE()+1, 120)) as 'EndToday'
Result:
StartToday EndToday ----------------------- ----------------------- 2008-09-22 00:00:00.000 2008-09-22 23:59:59.997 (1 row(s) affected)

(129)

