469,313 Members | 2,621 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

CompareValidator for dates > than today

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
2 9823

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

"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.

Similar topics

reply views Thread by Sjaakie Helderhorst | last post: by
1 post views Thread by Jorge EA | last post: by
3 posts views Thread by THaskell | last post: by
1 post views Thread by R.A.M. | last post: by
reply views Thread by =?Utf-8?B?VmFuY291dmVyTWlrZQ==?= | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.