比较第一和第二逻辑之间的日期 [英] compare dates between 1st and 20th Logic
本文介绍了比较第一和第二逻辑之间的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以请您分享一下您的逻辑吗.....
当前日期在当前月份的1号到20号之间,
我有点卡住..
can you please share your logic for this.....
current date is between the 1st and 20th of the current month,
I,m kinda stuck..
推荐答案
DateTime dt = DateTime.Now; // your input date
DateTime now = DateTime.Now; // current datetime
var abc = (dt.Day > 1 && dt.Day < 20) && dt.Month == now.Month ? true : false;
希望对您有帮助.
谢谢
-amit.
hope this will help you.
thanks
-amit.
尝试:
Try:
DateTime now = DateTime.Now;
DateTime dtFirst = new DateTime(now.Year, now.Month, 1);
DateTime dtTwentieth = new DateTime(now.Year, now.Month, 20);
DateTime test = new DateTime(2011, 12, 17);
if (test >= dtFirst && test <= dtTwentieth)
{
Console.WriteLine("Inside");
}
else
{
Console.WriteLine("Outside");
}
//dateStart,dateEnd are date time picker object
DateTime ds = dateStart.Value;
DateTime de = dateEnd.Value;
TimeSpan ts = de - ds;
int days = ts.Days;
这篇关于比较第一和第二逻辑之间的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文