sql server - Update SQL but only on fridays -
in database have 2 columns, 1 date , hour, have in hour column time interval , change. , every friday , put in specific hour nothing working.
this code search hour , change, , working:
update [dbo].[clockings] set [hour] = dateadd(second, (abs(checksum(newid())) % 900), '07:45:00.000') [hour] > '04:00:00.000' , [hour] < '07:45:00.000' update [dbo].[clockings] set [hour] = dateadd(second, (abs(checksum(newid())) % 900), '17:30:00.000') [hour] > '17:45:00.000' , [hour] < '23:59:59.000' to search date table nothing worked.
answer sql-server 2012 or later:
update clockings set ... datepart(dw, [date]) = 5; --friday note, check day first day of week. https://msdn.microsoft.com/en-au/library/ms181598.aspx
datename() function may suit.


Comments
Post a Comment