I have a need for showing recurrence dates on training table based on true/false field for everyYear field. And want to know how to handle that in SQL.
Here is the portion of the query that I need help with:
(this in Linq to Entities but I need it in T-SQL as L2E 3.5 won't handle it)
So I need to query the table and see
- If it is every year (I got that) then next year and the years after I show the records based on the month for example
If the training start date july 1 to end date july 30 then the record is displayed no matter what the year is based on today’s date?
- And also if the date taken is within this year then records is not displayed
- how do I handle a date from Dec 15 to Jan 15 (this is going to be the next year)
DateTime today = DateTime.Today.Date;
From t in db.train
from l in t.Trainees
Where today >= l.DateStarted && today <= l.DateEnded
Where not in ( ut.Passed == true && ut.DateTaken > l. DateEnded.Last year )