A query to check if a specific date falls on a weekend and if it does update the date to the monday following the weekend. Ex: date = 6/15/2024. This falls on a saturday. Update the date to 6/17/2024.
The query works as expected, however, curious to know if there is a shorter, efficient version. Thanks you experts!
declare @day int, date datetime
set @date = convert(varchar,getdate(),101)
select @day = datepart(dw, @date)
select case
when @day = 7 then @date + 2
when @day = 1 then @date + 1
else @date
end
update table_name
set run_date = @date
where id = 123
user3379269 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.