I want to select multiple records on the basis of a matching year, for example in table tab
where columns are [id] int
, [name] varchar
, [boo
SELECT [ACCNO]
,[Roll No]
,[IssueDate]
,[DueDate]
FROM [test1].[dbo].[IssueHis$]
WHERE [IssueDate] >= '20090101' AND
[IssueDate] < '20100101'
You could create a view that has the IssueYear as a separate column
CREATE VIEW vIssueHis
AS
SELECT
[ACCNO],
[Roll No],
[IssueDate],
[DueDate],
DATEPART(yyyy,IssueDate) as IssueYear,
DATEPART(yyyy,DueDate) as DueYear
FROM [test1].[dbo].[IssueHis$]
Then you could query the view like this
SELECT [ACCNO]
,[Roll No]
,[IssueDate]
,[DueDate]
FROM vIssueHis
WHERE IssueYear = 2009