Link to home
Avatar of Cosine_Consultants

asked on

Formating the date on an ASP web page

Hi, I am developing an ASP web application with an SQL server as my database. My problem is that I cannot view the dates I get from the database in the correct format (I want them to be in UK format). I set my SQL database date settings to UK dates, and I can see them through the SQL Server Enterprise Manager in UK format. I set the server machine to UK dates as well. My ASP pages on the other hand, display all the dates read from the database in US format; this hinders me from editing the dates in the format I want. I would like my interface to display/manipulate them in UK format. How can I fix this issue?

P.S. I even went ahead and changed my client machine settings to UK dates although this should be irrelevant in a web app...of course this did not fix the problem.

Avatar of apresto
Flag of Italy image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
This will set region setting of your ASP page to UK format.  I had the same problem once, drove me up the Mad!!!!
Avatar of sajuks

Just adding to apresto's posts, the below link should help u
either change it in the global.asa file or in each individual aps file
Avatar of Cosine_Consultants


I tried changing both the Globax.asax and the ASP file but still I have the problem !!!
I don't know if this is an issue, but I have a datalist control which is bound to the database table. The data are shown directly from the table to the datalists' textboxes.
hhuuumm....Not sure, im assuming your using .net then, though it was classic ASP, have a look here might help:
I've had this problem myself, even when setting all locales and session shenanegans, it would work for a period of time and then suddenly revert back to american date after 3-4 days.

The solution is used was to call a function to format my date every time i needed it.
Its a simple function, but it does the job.

function FormatDate(szDate)
  FormatDate = right("00" & day(szDate), 2) & " " & monthname(month(szDate), false) & " " & year(szDate)
end function

Obviously you can add paramters so you can remove the monthname part, or use "/" instead of " ", but thats the basics.


Dear Apresto,
I tried placing the <% session.lcid = 2057 %> on the top of my HTML web page but it didn't work. I then tried and placed it in the Page Load and it works fine.

Thank You all for your help.
Glad it worked, i assumed that you were using classic ASP thats why i suggested putting it in the top line,  Thanks