DateTime

G

Guest

If you have a text input field and you place a "comparevalidator" to ensure
that the field contains a date.... is there a method which allows you to
easily convert this into a date?

If I use the DateTime constructor, I have to pass the Year/Month/Day to the
constructor, but the CompareValidaror will accept a variety of different
formats for date so you are not quite sure where the parts of the date really
are. Do I have construct something which will parse the text field and find
the Year/Month/Day or is there and easier way?

Thanks in advance for your assistance!!!
 
R

Riki

Jim said:
If you have a text input field and you place a "comparevalidator" to
ensure that the field contains a date.... is there a method which
allows you to easily convert this into a date?

If I use the DateTime constructor, I have to pass the Year/Month/Day
to the constructor, but the CompareValidaror will accept a variety of
different formats for date so you are not quite sure where the parts
of the date really are. Do I have construct something which will
parse the text field and find the Year/Month/Day or is there and
easier way?

Thanks in advance for your assistance!!!

myDateVariable = CDate(myStringVariable)
 
S

Scott Allen

Set the Type property of the CompareValidator to Date and you won't have
to perform the conversion yourself. I'd suspect the conversion to a date
type by the validator would be done with the current locale settings.
 
V

Vanni Tomezzoli

If I well remember, you should try:

DateTime myDate = DateTime.Parse(txtDate.Text);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,230
Latest member
LifeBoostCBD

Latest Threads

Top