Arnaud Ad Arnaud Ad - 1 year ago 121
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 Source

according to @Totero answer this can help

from u in Utilisateurs
where (DateTime.Now.Date - u.DateNaissance).TotalDays <=30
select u
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download