473,656 Members | 2,871 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1520
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.

<globalizatio n 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******** ********@TK2MSF TNGP15.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.

<globalizatio n 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******** ********@TK2MSF TNGP15.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
3685
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 DD/MM/YYYY. However if the day is less than 12 the day then becomes the month e.g. 3 July 2003 is displayed in Visual Basic as 7 March 2003. So if I have two records with different dates as such 6/8/03 and 15/8/03 the first date is 8 June 2003...
0
1335
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 datatype. The most significant is dates, by providing the date in the proper XML format IE will display the date in a nice readable format. But being in Ausrtralia I am expecting my date format to be displayed like so : dd/mm/yy It is...
2
1953
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 like to know how to overcome this and why it does it. Public Function HowDays(StartDate As Date, EndDate As Date) As Integer 'Get the number of workdays between the given dates
12
6365
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 ranges, ie between 24/09/2004 and 01/10/2004 together with 05/10/2004 and 07/10/2004 ? If I enter the "Between" criteria on different lines it returns no data.
5
8234
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 I change the format of the textbox from short date to medium or long date, the date appears as it is supposed to. I also have a calendar control in another form that is linked to a date field in a table. When you choose, say 3rd August, it...
2
1543
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. However, my Web app is not accepting dates of format dd/MM/yyyy only MM/dd/yyyy
7
1246
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 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,
9
1728
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 DateTime object to "act" american. Let me give an example: In order to take in an american date, I tell it which culture the date will be formatted according to:
3
2154
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 UKDate() function seems correct: Function UKDate(varDate As Variant) As String If IsDate(varDate) Then
0
8297
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8717
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8600
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7311
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1930
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.