I am trying to capture a specific day of the week in a long list of dates (TxnDate). The below command I am using is throwing the following error:
Invalid column name 'TxnDay'.
Code
Select DATENAME(dw, ft.[TxnDate]) as TxnDay, ft.[ProductCode], ft.[Site] from dbo.FactTransactions as Ft
Where ft.[Site] = '1' and TxnDay = 'Tuesday'
EDIT: I have also tried the below with the following error:
Invalid column name 'TxnDay'.
Select ft.[TxnDate], ft.[ProductCode], ft.[Site] from
dbo.FactTransactions as Ft
Where ft.[Site] = '1' and ft.[TxnDate] in (SELECT DATENAME(dw, ft.
[TxnDate]) as TxnDay where TxnDay = 'Sunday')