Dear There
I have one web application created in asp.net. i hosted the website on one american server. As the site was on american server so i did all scripting for date checks and conversion by keeping in mind the format mm/dd/yyyy. Now after one and half year i have switched my site from that server to new server but unfortunatly this new server is in uk and that is why the date format configured on server is dd/mm/yyyy.
As i have uploaded all the things on the server and have made it live as well so it is not possible for me to reinstall the server and change the date format i.e to change it to dd/mm/yyyy.
Now the problem i am facing is server side script is doing date checks and display in dd/mm/yyyy, which is not required.
I trued changing dateformat from global settings also but it didnt work although i was aware intitally also that it work. Because as per my exp i have concluded that somewhere in system the date format got stored at installation time and after that changing that is not possible without re-installtion.
so, if anyone can help me how to change/set the date format in the application to mm/dd/yyyy, without re-installing the server. i think some thing like localize settings will have to do with it, but what i dont know...

Recommended Answers

All 7 Replies

Learn about Globalization and Localization.

Thanx
But i have used global tags in web.config as well but not effecting anything. as per my understanding global & Localization only meant how it will be displayed on user machine. But my problem is server specific. and aparently after what ever research i have done, there is no way to slove this issue without reinstallation of windows with the language and regional settings needed.

repair the database design
dates and times are correctly stored as a timestamp, 10 digit number of seconds from 1/1970, not as a text date field, the data is supposed to be machine readable, the output human readable
a cron job or script update to fix your design fault is quick and easy
update table add column timestampselect id date
convert date to timestamp
update id timestamp with calculated valueupdate table delete column date
date functions are simply numeric
output formatting is done on output, output can adjust to user settings
you have a smaller faster database that the information can be put to the user in the form they expect without altering the data
win win

thanx almostbob
but the problem is not related to saing and retrieving data from the databse.
The problem is in asp.net script.
let me explain you further about the scenario.
on clicking one button this if condition is there

if date1>date2 then do something

now on new server even if i pass date like this to date1 (JUL/01/09) and date2(may/13/09) system is saying date2 is greater because it is reading this as 07-01(Jan)-09 and other as 13-05(may)-09.

this is happening becuase the indows has been installed for the UK region with all default settings of UK, which makes date reading as DD/MMM/YYYY bydefault.

thanx almostbob
but the problem is not related to saing and retrieving data from the databse.
The problem is in asp.net script.
let me explain you further about the scenario.
on clicking one button this if condition is there

if date1>date2 then do something

now on new server even if i pass date like this to date1 (JUL/01/09) and date2(may/13/09) system is saying date2 is greater because it is reading this as 07-01(Jan)-09 and other as 13-05(may)-09.

this is happening becuase the indows has been installed for the UK region with all default settings of UK, which makes date reading as DD/MMM/YYYY bydefault.

REPEAT
Dates are not stored as text
Dates are correctly stored as a timestamp, 10 digit number representing the number of seconds from 1/1/1970
Date/time comparisons are then simply numeric
repair the database design so that there are no text representations of dates
recode your .asp to operate properly
Problem solved

Trying to write this in plain english without jargon(damn its hard)

SQL in every version has many data constructs, the most efficient data constructs ignore human readability.
timestamp is more efficient than any text date representation becausedate/time compare functions always work,
select range of dates/times always works,
date and time are stored as a smallint 10bytes instead of a text 50bytes (a big deal in v.large databases) eg.
1234567890 vs
February 13, 2009, 11:31:30 pm greenwich mean time
globalisation or localisation of time is simple the timestamp is stored at utc, so localisation is known to the server
localisation of output format is simple by the date format strings already familiar
regardless of the date format used for input or output the stored data is always correct in any os version.
the user interface remains the same

select from database where timestamp >1234567890 and timestamp < 1234568890

is very much faster
text date time representations of the timestamp are the reason for sql date functions having declaratives to output day month year hour minute second, from a numeric string
correcting the database design to store the date and time as a timestamp is a relatively simple task, as is recoding the asp to operate on timestamps instead of text date
it is more efficient to input in human readable form
convert to timestamp on validation
store the timestamp
select/process/report on basis of timestamp
format to human readable on output
than to try and select/process/report on basisi of textual representations

a single cron job or an .asp program to recode the database to current best practice is simpler than it appears before the attempt is made
the server OS version becomes irelevant
the date can be output in any form as sql asp are independent of the text date on the server.

Thanx
But i have used global tags in web.config as well but not effecting anything. as per my understanding global & Localization only meant how it will be displayed on user machine. But my problem is server specific. and aparently after what ever research i have done, there is no way to slove this issue without reinstallation of windows with the language and regional settings needed.

You have a misunderstanding about globalization & localization. It is server specific API. Your problem's solution is Globalization/Localization.

Write following entry to set British English culture (writing system, calendars in use, date and time formatting conventions, numeric and currency conventions, and sorting rules.)

<system.web>
....
<globalization culture="en-GB" uiCulture="en-GB"/>
...
</system.web>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.