sql server - Update SQL but only on fridays -


enter image description here

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.

enter image description here

answer 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

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -