CurrentCulture's ShortDateFormat

lasagna

New member
Joined
May 29, 2006
Messages
1
Programming Experience
1-3
Hi guys,

I'm working on a project that processes a lot of information, mostly dates stored as Strings (since they can be Null in the database).
So far this code worked great:

VB.NET:
[COLOR=#0000ff]Dim[/COLOR] strDate [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR] = Now.ToString(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)
Label1.Text = strDate
[COLOR=#0000ff]Dim[/COLOR] dtDate [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]Date
[/COLOR]dtDate = Convert.ToDateTime(strDate, System.Globalization.CultureInfo.CurrentCulture)
Label2.Text = dtDate.ToString

But once I use a white-space as dateseparator in the windows regional settings it crashes when using convert.toDateTime.
Any idea's how to get around this? :confused:

Thanks in advance,

Rob

 
try this

VB.NET:
dim dt as date = date.today 'set as todays date
label2.text = Cstr(dt) 'convert date to string
the output to label2 will look like this
25/10/2006
 
Back
Top