Ed
asked on
Asp/Net Validation date Issue
I have a sub that checks the minimum value of a textbox
It worked until yesterday(31/10/2016)
Now today (01/11/2016)
I get the below error
I know its something to do with it reading the date as a string but can't find the right solution... help. Thanks
Public Sub ValidCheck()
rvCompDateCheck.MinimumValue = DateTime.Today.AddDays(-7).ToShortDateString()
rvCompDateCheck.MaximumValue = DateTime.Today.ToShortDateString()
End Sub
It worked until yesterday(31/10/2016)
Now today (01/11/2016)
I get the below error
The MaximumValue 01/11/2016 cannot be less than the MinimumValue 25/10/2016 of rvCompDateCheck.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The MaximumValue 01/11/2016 cannot be less than the MinimumValue 25/10/2016 of rvCompDateCheck.
I know its something to do with it reading the date as a string but can't find the right solution... help. Thanks
Try..
Dim x As DateTime = DateTime.Now
rvCompDateCheck.MaximumVal ue = x.ToShortDateString()
x = now.AddDays(-7)
rvCompDateCheck.MinimumVal ue = x.ToShortDateString()
Dim x As DateTime = DateTime.Now
rvCompDateCheck.MaximumVal
x = now.AddDays(-7)
rvCompDateCheck.MinimumVal
Looks like a format issue, try below if above is not working..
DateTime.Today.ToString("y yyyMMdd")
Public Sub ValidCheck()
rvCompDateCheck.MinimumVal ue = DateTime.Today.AddDays(-7) .ToString( "yyyyMMdd" )
rvCompDateCheck.MaximumVal ue = DateTime.Today.ToString("y yyyMMdd")
End Sub
DateTime.Today.ToString("y
Public Sub ValidCheck()
rvCompDateCheck.MinimumVal
rvCompDateCheck.MaximumVal
End Sub
ASKER
Thanks
the above works...almost.
No error anymore but it is not picking up on the fact that
31/10/2016 is less than 01/11/2016
It needs to be UK format I think.
the above works...almost.
No error anymore but it is not picking up on the fact that
31/10/2016 is less than 01/11/2016
It needs to be UK format I think.
Hi edjones1,
Glad that it helped !!
Regards,
Pawan
Glad that it helped !!
Regards,
Pawan
ASKER
any ideas on how to read it in uk format?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi edjones1,
Any update on this?
Regards,
Pawan
Any update on this?
Regards,
Pawan
ASKER
That worked, thanks
ASKER
Open in new window