You should never store a localized date string in a database.
You must save the dates in the date columns and then localize the data when it is displayed.
1. Set the locale of your UI site
In this example, set lang as requested, but may have a different mechanism.
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) Dim lang As String If HttpContext.Current.Request.Path.Contains("/en/") Then lang = "en" 'english' ElseIf HttpContext.Current.Request.Path.Contains("/pt/") Then lang = "pt" 'portugues' Else lang = "es" 'español, the default for the site' End If Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(lang) Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang) End Sub
2. Get input variables up to date
Retrieving data from text input is simple, this is an example, but you should be fine with checking the date.
dim theDate as date if IsDate( txtDate.text ) then theDate = DateTime.Parse(txtDate.text) else 'throw exception or something end if
Edit
Since you say you cannot change the way it is stored, you have big problems if you don't have a db entry to tell the date format. The problem is not separators, but when you find a date like 6/3/2009, you don’t know if it is March 6th or June 3rd.
source share