|
-
Jul 27th, 2006, 05:36 AM
#1
Thread Starter
Fanatic Member
Compare two Dates.
hi guyz! Currently, i have the code below
Code:
if (dtpDate.Value.ToShortDateString != DateTime.Now.ToShortDateString)
{
result = MessageBox.Show(this,"The date is not the date today.", "BCMD", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
MessageBox.Show(this, result.ToString ());
}
but when try to run it it gives me an error saying "Operator '!=' cannot be applied to operands of type 'method group' and 'method group'". Can anybody please tell me what is the right way to compare two dates? thanks in advance!!!
-
Jul 27th, 2006, 05:41 AM
#2
Re: Compare two Dates.
Why not just use DateTime.Compare() method to compare the dates?
Use [code] source code here[/code] tags when you post source code.
My Articles
-
Jul 27th, 2006, 05:44 AM
#3
Fanatic Member
Re: Compare two Dates.
add () after ToShortDateString if you are using c#.
-
Jul 27th, 2006, 05:48 AM
#4
Re: Compare two Dates.
Yes, because what you're doing currently is comparing object methods. You need to add the argument list parentheses () to actually call the method and use its return value.
Note that you don't need to call that method at all, if all you want to do is compare the date values.
-
Jul 28th, 2006, 12:32 AM
#5
Thread Starter
Fanatic Member
-
Jul 28th, 2006, 12:34 AM
#6
Thread Starter
Fanatic Member
-
Jul 28th, 2006, 12:57 AM
#7
Re: Compare two Dates.
Unless you have any further questions please go to the "Thread Tools" menu above the first post and click "Mark Thread Resolved". This will let other forum users know your question has been answered. Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|