【发布时间】:2017-02-10 23:00:26
【问题描述】:
我有两个文本框(开始日期,结束日期)。 如果 startdate 和 enddate 值介于 startDate 月份的任何一个月的 21 日和下个月的 20 日之间,我可以做任何其他事情。
例如,
startdate(25/jan/2017) 和 enddate(20/feb/2017) : 可以做任何逻辑
startdate(25/jan/2017) 和 enddate(21/feb/2017):无法执行逻辑
我为此使用了一些逻辑,
if ((startDate2.Day >= 21 && endDate2.Day >= 21 && emonth == smonth)
|| (startDate2.Day >= 21 && endDate2.Day <= 20 && emonth == smonth + 1)
|| (startDate2.Day <= 20 && endDate2.Day <= 20 && emonth == smonth)
|| (startDate2.Day <= 20 && endDate2.Day >= 21 && emonth == smonth - 1))
{
}
但它不适用于 startdate(12 月)和 endDate(1 月),因为 ((startDate2.Day <= 20 && endDate2.Day >= 21 && emonth == smonth - 1)) 任何人都可以帮助我正确的逻辑吗?
【问题讨论】:
-
应该例如允许从同月的 8 日到 15 日吗?