In order to improve Canadian customer service, we are trying to localize the dates displayed on some of the old classic ASP pages. We successfully started using the SetLocale () vb script function - we correctly process user input dates.
However, I expected that the date returned by ADODB.Recordset would respect the locale. Consider the following code:
SetLocale 4105 ''' ' Get a list of Employees SQL = "SELECT Firstname, Lastname, HireDate FROM Employee" Set conn = Server.CreateObject("ADODB.Connection") conn.Open Application("ConnectionString") Set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = conn cmd.CommandType = 1 cmd.CommandText = SQL Set rst = Server.CreateObject("ADODB.Recordset") rst.CursorLocation = 3 Set rst = cmd.Execute
When a HireDate column is written to a page, it is displayed as MM / DD / YYYY (the format used by our servers).
A few notes:
- We need to serve both American and Canadian clients on the same server (therefore changing the localization / region of the server is not an option). This should be a clean software solution.
- I noticed that TypeName of rst ("HireDate") - "Field" is not a date, as I expected.
What is the correct way to localize the date values ββcoming from the SQL server in this scenario?
source share