下午好会员, 我想在数据库中查看生日
使用函数
提供以下信息class person
public property dateofbirth as nullable(of datetime)
end class
public function allperson() as Ienumrable(of preson) implements databank.allpersons
return _contact.values.oftype(of person).orderby(function(c) c.name)
end function
public function birthday (startdate as date, Enddate as date) as IEnumerable (of Person) Implements databank.birthdaybetween
/.... ???
end function
这是我的问题的图片 http://s8.postimg.org/vn4ufpmqt/problem.png
感谢 ELISA
答案 0 :(得分:0)
假设生日函数应该返回所有在startdate和enddate之间的时间范围内庆祝生日的人,以下查询应该有效:
Return (From x In allperson() _
Where x.DateOfBirth.HasValue AndAlso x.DateOfBirth.Value.Year <= startdate.Year
AndAlso ((startdate.Month = x.DateOfBirth.Value.Month AndAlso startdate.Day <= x.DateOfBirth.Value.Day) _
OrElse (startdate.Month < x.DateOfBirth.Value.Month)) _
AndAlso ((x.DateOfBirth.Value.Month = enddate.Month AndAlso x.DateOfBirth.Value.Day <= enddate.Day) _
OrElse x.DateOfBirth.Value.Month < enddate.Month)).AsEnumerable()