Filter in a SQL view to make column show records with current year
filter, sql, view
Solution
You can use a "year" function on your datetime variable, like this:
SELECT * FROM TableName WHERE YEAR(date) = 2013
or if the current year needs to be dynamic:
SELECT * FROM TableName WHERE YEAR(date) = YEAR( getDate() )
Problem
I tried to find other questions that may have answered this but nothing really related to what I'm doing. I am making a view that has two joined tables in it. I need records to show up that only have the current year in the date, so when I make a report in Visual Studio, the user will only be able to see what has been done for the current year. I have experience in Access but am still trying to figure out SQL.