Hi Samedha,
Check this example. Now please take its reference and correct your code.
Database
For this example I have used of Northwind database that you can download using the link given below.
Download Northwind Database
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
int year = 1958;
int week = 1;
NorthwindEntities db = new NorthwindEntities();
int prodtnqty = (from emp in db.Employees
where Math.Floor((decimal)DayOfYear(emp.BirthDate) / 7).Equals(week)
&& emp.BirthDate.Value.Year == year
select new
{
Year = emp.BirthDate.Value.Year,
Week = Math.Floor((decimal)DayOfYear(emp.BirthDate) / 7),
Employee = emp
}).ToList().Count();
}
[System.Data.Entity.DbFunction("Edm", "DayOfYear")]
public static System.Int32? DayOfYear(System.DateTime? timeValue)
{
throw new NotSupportedException("");
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim year As Integer = 1958
Dim week As Integer = 1
Dim db As NorthwindEntities = New NorthwindEntities()
Dim prodtnqty As Integer = (From emp In db.Employees _
Where Math.Floor(CDec(DayOfYear(emp.BirthDate)) / 7).Equals(week) AndAlso emp.BirthDate.Value.Year = year
Select New With {Key _
.Year = emp.BirthDate.Value.Year, Key _
.Week = Math.Floor(CDec(DayOfYear(emp.BirthDate)) / 7), Key _
.Employee = emp
}).ToList().Count()
End Sub
<System.Data.Entity.DbFunction("Edm", "DayOfYear")>
Public Shared Function DayOfYear(ByVal timeValue As System.DateTime?) As System.Int32?
Throw New NotSupportedException("")
End Function
Screenshot