Getting the Date for the Previous Saturday with T-SQL
SQL
Example of how to get the date for the previous Saturday for the current date using T-SQL.
/*SYNTAX*/ DATEADD(DAY, DATEDIFF(DAY, 5, GETDATE()) / 7 * 7, 5) /*EXAMPLE*/ SELECT ORDER_NO, PRODUCT_ID FROM ORDERS WHERE ORDER_DATE = DATEADD(DAY, DATEDIFF(DAY, 5, GETDATE()) / 7 * 7, 5)
7
7
6
6
6
5