String To Date

M

MattB

Hi, I have a vb.net/asp.net 1.1 web application that may be used in
other cultures where dates are formatted differently. I have three
controls (either DropDowns or TextBoxes) one for year, one for month,
and one for day.

I'd like to be able to convert this to a DateTime type of variable and
not have to rely on or find the localization settings.

My idea was to populate the DateTime.Year, DateTime.Month and
DateTime.Day from the controls, (like Date.Year = txtYear.Text) but
those properties are read-only.

I know I could make a string like "12-19-2005" and do a
strDate.ToDateTime but that will break as soon as the application is
used where dd-mm-yyyy is the norm.

So If I have three variables representing year, month, and day what's
the best way to convert to Date without relying on any kind of
localization setting? Thanks!

Matt
 
D

Daniel TIZON

it works in ASPNET 2.0,
it should work in ASP.NET1.x

Dim MyDate As New DateTime(2005, 12, 19)
 

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

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top