Quite often I need to select all records in a table where the date is equal to today. The GETDATE() function in Transact-SQL returns the date and the time. The time vlaue can be stripped off by subtracting each part (hour, minute, second, millisecond).
- DATEADD(hh, -DATEPART(hh, GETDATE()), DATEADD(mi, -DATEPART(mi, GETDATE()), DATEADD(s, -DATEPART(s, GETDATE()), DATEADD(ms, -DATEPART(ms, GETDATE()), GETDATE()))))
You need to login to post a comment.