Joseph Michael Pesch
VP Programming

SQL Beginning of Day and End of Day (getdate() Date Only)

by 16. August 2009 21:05

declare
@ProcessDate datetime
, @ProcessDateMin datetime
, @ProcessDateMax datetime

set @ProcessDate =getdate()

set @ProcessDateMin =convert(datetime,floor(convert(float, @ProcessDate)))

set @ProcessDateMax =dateadd(hour, 23,dateadd(minute, 59,dateadd(second, 59, @ProcessDateMin)))


select @ProcessDate ProcessDate, @ProcessDateMin ProcessDateMin, @ProcessDateMax ProcessDateMax

ProcessDate             ProcessDateMin          ProcessDateMax
----------------------- ----------------------- -----------------------
2009-08-16 15:18:16.233 2009-08-16 00:00:00.000 2009-08-16 23:59:59.000

Tags: ,

SQL Server

Comments are closed