Hello guys. I want something like this.

if(getdate(month) == 1 && getdate(day) == 5) // 5 January
   // do code
else if(getdate(month) == 12 && getdate(day) == 11) // 11 December
   // do another code
// ...

Is that possible ?

8 Years
Discussion Span
Last Post by CloneXpert


ofcourse, create a DateTime object, check out it's constructors and choose the one you like, then access the needed properties like this:

DateTime date = new DateTime();
if(date.Month == 5  ...

if(date.Day == ...

check out the other properties aswell :) i'm sure you can find everything there what you need :)


hmm, if i do like this:

DateTime date = new DateTime();

textBox1.Text = date.Month.ToString();

in my textbox will be: 1

And my month pc date is 3 ( March )

Edited by charqus: n/a


yes because you didn't specify any details for "date". This is why I said when you instantiate pick the constructor which you need (when you write "new DateTime(" press the down arrow key to scroll through the variations and pick the one you like:

DateTime date = new DateTime(2010,7,11);


if you would like to get the current date write

DateTime date = DateTime.Now;

I hope you understand now

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.