I am attempting to insert tomorrow’s date at 10:00:00 into SQL Server 2005/2008.
I currently have
DATEADD(dd, 1, GETDATE())
which gives me tomorrow’s date fine, however I have tried a number of methods to also concat / set the time to 10:00:00.
Example:
Current Time: 2013-01-07 15:37:05
Required Insert Date: 2013-01-08 10:00:00
You can use a combination of
DATEADDandDATEDIFF.DATEDIFF(dd,0...)truncates the time part of a date, hence “rounds” to midnight andDATEADD(hh,10...)adds 10 hours.DEMO