Click here to Skip to main content
15,900,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can you please share your logic for this.....
current date is between the 1st and 20th of the current month,
I,m kinda stuck..
Posted

C#
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;


hope this will help you.

thanks
-amit.
 
Share this answer
 
Comments
Mninawa 1-Dec-11 4:17am    
var abc = (dt.Day >= 1 && dt.Day <= 20) && dt.Month == now.Month ? true : false;
AmitGajjar 1-Dec-11 6:47am    
yes, sorry it's inclusion of 1 & 20.
Try:

C#
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");
    }
 
Share this answer
 
C#
//dateStart,dateEnd are date time picker object
DateTime ds = dateStart.Value;
DateTime de = dateEnd.Value;
TimeSpan ts = de - ds;
int days = ts.Days;
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900