sql - DATEDIFF - How many days until Sunday -
in sql server, trying write age-off report inventory purposes. each week, inventory system marks thousands of rows deletion. takes place on sundays @ 06:00:00 part of weekly sql db purge schedule.
using (yyyy-mm-dd hh:mm:ss:ms) format closed_time, how can calculate numbers of days between date, until next sunday of current week? , more elaborate, there way narrow down exact dd:hh:mm? problem each client's sunday db schedule purge varies. might difficult compute. might easier calculate whole days until sunday 00:00:00. tried using datediff function no success.
select yada datediff(day, closed_time,dw) days_until_purged db1 closed_time desc
thx in advance
try this:
select 8-datepart(w, closed_time) days_until_purged db1 ...
Comments
Post a Comment