Problem with Dates

L

Lars Netzel

On Server1 when running my ASP:NET application and selecting records from an
SQL server the Dates show up in Swedish Format (yyyy-mm-dd) this is good
this is what I want.

Right now we are setting up a new server (Server2) with a SQL server as
well.. here the dates show up in this format (mm/dd/yyyy) and this I dont'
like.

I have set both servers to useer Swedish Reginoal and localtion settings in
Windows Server 2003 and I have checked the Coalision Name for the two SQL
servers and they are the same. But still it differs in the ASP:NET
applicaion. What other settings can I check.

What else can I check? I need this two two show the dates the same what
without using CultureInfo things on the thread or any own convert functoins.

is it the IIS or the SQL server who is responsible for these convertions?

best regards
/Lars Netzel
 
J

Jarmo Muukka

If you return datetime as datetime and you have in your C# or VB .NET code
DateTime or SqlDateTime data type, then it is responsible of the ASP.NET
part of the code to format the datetime to string. You either use ToString()
with correct format provider (Culture) or you use it without format provider
(ToString() without parameters) then current thread's culture will be used.

If you want to hardcode the format, you can use ToString() with correct
format provider or if you're using databinding, then you should look for
Eval-method's parameters in aspx page.

My suggestion is to set current thread's culture to what ever you want at
runtime when the page is loaded. You know the user and therefore you know
the culture of the user (if you have that info). This is easy to do. Just
few lines of code to your base class of your pages.

JMu
 

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

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top