Arnaud Ad Arnaud Ad - 3 months ago 25
SQL Question

convert a SQL query to LINQ (DateDiff, DateAdd)

i'm facing difficulties to translate this in LINQ:

SELECT * FROM Utilisateur WHERE (DATEDIFF(dd, getdate(), DATEADD(yyyy, DATEDIFF(yyyy, DateNaissance, getdate()), DateNaissance)) + 365) % 365 <= 30

Thanks in advance for your help


according to @Totero answer this can help

from u in Utilisateurs
where (DateTime.Now.Date - u.DateNaissance).TotalDays <=30
select u