I have a date 2013-12-14 05:00:00.000 in my table.
Now i want to update only time of that date. E.G to 2013-12-14 04:00:00.000
Is there any query to update o
In case of just updating a particular part of the datetime you can use SMALLDATETIMEFROMPARTS
like:
UPDATE MyTable
SET MyDate = SMALLDATETIMEFROMPARTS(YEAR(MyDate), MONTH(MyDate), DAY(MyDate), , )
In other cases it may be required to copy parts of datetime to other or update only certain parts of the datetime:
UPDATE MyTable
SET MyDate = SMALLDATETIMEFROMPARTS(YEAR(MyDate), MONTH(MyDate), DAY(MyDate), DATEPART(hour, MyDate), DATEPART(minute, MyDate))
Refer SQL Server Date/Time related API references for more such functions