Arnaud Ad Arnaud Ad - 1 month ago 6
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

Answer

according to @Totero answer this can help

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