By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,717 Members | 2,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,717 IT Pros & Developers. It's quick & easy.

CompareValidator for dates > than today

P: n/a
I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot
be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?

Thanks,

Tom
Jan 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

tshad wrote:
I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot
be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?

Thanks,

Tom


How about this:

ValueToCompare = '<%= DateTime.Today.ToShortString() %>'

put a semi-colon to the end of the ToShortString() if using C#. See if
that works

Jan 13 '06 #2

P: n/a

"tdavisjr" <td******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

tshad wrote:
I am trying to check the date of my field to check if it is greater that
today, but I am getting an error.

I am using :

<asp:CompareValidator runat="server"
ControlToCompare="RequestedStartDate"
Operator="GreaterThan"
Display="Dynamic"
ValueToCompare = DateTime.Today.ToShortDateString()
Type="Date" text="<br>Invalid Start Date"/>

But it gives me an error:

The value 'DateTime.Today()' of the ValueToCompare property of '' cannot be converted to type 'Date'

I also tried DateTime.Today(), but got the same error. How would I do this?
Thanks,

Tom


How about this:

ValueToCompare = '<%= DateTime.Today.ToShortString() %>'

put a semi-colon to the end of the ToShortString() if using C#. See if
that works

That was what I was looking for.

Thanks,

Tom
Jan 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.