Query Prior Friday From SQL Server
SQL Server TSQL query to return the last friday, based on the current date. This technique can also be modified to return any other day of the week or to get the next Friday, etc.
--Returns previous friday based on the current date
SELECTEND_DATE = DATEADD(d, (DATEDIFF (d, '20000108', GETDATE()) / 7) * 7, '20000107')
SELECTEND_DATE = DATEADD(d, (DATEDIFF (d, '20000108', GETDATE()) / 7) * 7, '20000107')
No comments:
Post a Comment