Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi from getdate(), how can i get today's date with specific time :For example : (i just need specific 11oclock today)2014-07-08 11:00:00.000This do the trick : select DATEADD( HH, 11, CAST(CAST(DATEADD(DAY,-1,GETDATE()) AS INT) AS DATETIME))But at second half of the day it changed from 2014-07-08 11:00:00.000 to the next day, i dont know why~~~who controls the past controls the future, who controls the present controls the past. ¯\(º_o)/¯ ~~~
webfred
Master Smack Fu Yak Hacker
8781 Posts
Posted - 2014-07-08 : 04:41:31
try this:
selectgetdate() as [Getdate],dateadd(day,datediff(day,0,getdate()),0) as [Date 00:00],dateadd(hour,11, dateadd(day,datediff(day,0,getdate()),0) ) as [Date with specific hour]