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 ?

Hey

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 :)

thank you

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 )

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.