473,405 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Using american dates by default

Hi guys,

I'm developing a web app on a UK computer. When I put a date into a textbox,
its in the format DD/MM/YY. The DateTime object takes that in and handles
in perfectly.

Now, I need to start using the american format MM/DD/YY.

My question is, how do I get the DateTime object to recognise what I'm passing
in as an American date? If the machine is installed on an american server,
will it immediately expect the dates as american? Or do I need to do something
else?

Many thanks

Simon
Feb 10 '06 #1
6 1508
thechaosengine wrote:
I'm developing a web app on a UK computer. When I put a date into a textbox,
its in the format DD/MM/YY. The DateTime object takes that in and handles
in perfectly.

Now, I need to start using the american format MM/DD/YY.

My question is, how do I get the DateTime object to recognise what I'm passing
in as an American date? If the machine is installed on an american server,
will it immediately expect the dates as american? Or do I need to do something
else?


You can tell DateTime.Parse which CultureInfo to use. If you don't
specify anything, it uses the CultureInfo for the current thread.

Jon

Feb 10 '06 #2
> You can tell DateTime.Parse which CultureInfo to use. If you don't
specify anything, it uses the CultureInfo for the current thread.

Jon


Sorry to hijack slightly, however how do you instruct SQL server to save
dates in UK format?

The DateTime class again maintains my uk date however SQL writes it out in
america format, any clues ideas?

Thanks,
Taz
Feb 10 '06 #3
Hello Jon Skeet [C# MVP],

OK, thats cool.

Now, just one last thing. Would I be right in thinking that if the code is
running on an american server, it will default to the american way of doing
dates?

I'm pretty sure it should...

Thanks

Simon
Feb 10 '06 #4
re:
The DateTime class again maintains my uk date however SQL writes it out in america format, any
clues ideas?
If you want dates to be displayed using uk format, set "culture" and "uiCulture",
in the globalization section of web.config, to "en-GB".

Anything you display in ASP.NET pages from that point on,
will be displayed using UK date and currency formats.

<globalization culture="en-GB" uiCulture="en-GB" />

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Tarun Mistry" <uk***********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
You can tell DateTime.Parse which CultureInfo to use. If you don't
specify anything, it uses the CultureInfo for the current thread.

Jon

Sorry to hijack slightly, however how do you instruct SQL server to save dates in UK format?

The DateTime class again maintains my uk date however SQL writes it out in america format, any
clues ideas?

Thanks,
Taz

Feb 10 '06 #5
thechaosengine wrote:
OK, thats cool.

Now, just one last thing. Would I be right in thinking that if the code is
running on an american server, it will default to the american way of doing
dates?

I'm pretty sure it should...


*Probably*. If it's an ASP.NET app, you may find it takes the UI
culture (set on the thread from what the browser provides) rather than
the "normal" culture. I can't remember off the top of my head.
Definitely try it on a US-based server with browser settings for US and
UK.

Jon

Feb 10 '06 #6
Hi Juan

Your code has been proved a gr8 help to me. Thnx a lot.

Ruju
"Juan T. Llibre" wrote:
re:
The DateTime class again maintains my uk date however SQL writes it out in america format, any
clues ideas?


If you want dates to be displayed using uk format, set "culture" and "uiCulture",
in the globalization section of web.config, to "en-GB".

Anything you display in ASP.NET pages from that point on,
will be displayed using UK date and currency formats.

<globalization culture="en-GB" uiCulture="en-GB" />

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Tarun Mistry" <uk***********@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
You can tell DateTime.Parse which CultureInfo to use. If you don't
specify anything, it uses the CultureInfo for the current thread.

Jon

Sorry to hijack slightly, however how do you instruct SQL server to save dates in UK format?

The DateTime class again maintains my uk date however SQL writes it out in america format, any
clues ideas?

Thanks,
Taz


Mar 16 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ray | last post by:
Date problem. Using non American date formats with Microsoft Access and Visual Basic. I set my regional settings to English(Ireland) or English(United Kingdom) and my date appears in Access as...
0
by: GMG | last post by:
Background : with XML data islands you can bind data to HTML tags. If you do not provide a DTD it will display the information as is. If you provide a DTD IE will display the data according to its...
2
by: Hutton | last post by:
This code works fine, the Windows regional settings are UK (dd/mm/yyyy) but when it reads the record set it recognises them as US dates - mm/dd/yyyy. All dates are formatted as short dates. Would...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
5
by: Daveo | last post by:
Hi there, I'm having a problem with my database changing the date that I enter in the format dd/mm/yyyy into American format. Bizarrely, when enter the date in a textbox it changes round, but if...
2
by: Grant Merwitz | last post by:
Hi I have installed my web app on a Windows 2003 server. The Regional and Language was originally set to American. Now we have changed it to UK, and are trying to get the DateFormat right. ...
7
by: thechaosengine | last post by:
Hi guys, I'm developing a web app on a UK computer. When I put a date into a textbox, its in the format DD/MM/YY. The DateTime object takes that in and handles in perfectly. Now, I need to...
9
by: Simon Harvey | last post by:
Hi all, I'm having a bit of a problem working with dates. My computer is british, but I'm developing an american application so I therefore need to use american dates. But I can't get my...
3
by: tom26pr | last post by:
Hi there, When trying to query the DB with the following: ...WHERE ((filed)>=" & UKDate(sFromDate) & " And (field)<=" & UKDate (sToDate) & ") I'm getting output in american format. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.