473,386 Members | 1,715 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,386 software developers and data experts.

Dates

Hello all,

we have an app with works across the globe, and therefore dates are
displayed in a number of formats, such as dd/MM/yyyy (uk) and MM/dd/yyyy
(usa). When our app has it's language set to ENGLISH everything works fine,
but when it's set to AMERICAN the dates fail as we're trying to cast a date
such as 16/04/2007 to a US DateTime.

What I need to know is, no matter what culture/language you're in how do you
cast the dates a date dd/MM/yyyy.

Thanks,

Jon
Apr 17 '07 #1
11 1130
"Jon" <Jo*@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
Hello all,

we have an app with works across the globe, and therefore dates are
displayed in a number of formats, such as dd/MM/yyyy (uk) and MM/dd/yyyy
(usa). When our app has it's language set to ENGLISH everything works
fine,
but when it's set to AMERICAN the dates fail as we're trying to cast a
date
such as 16/04/2007 to a US DateTime.

What I need to know is, no matter what culture/language you're in how do
you
cast the dates a date dd/MM/yyyy.
DateTime MyDateTime = <get your date from somewhere>;
MyLabel.Text = MyDateTime.ToString("dd/MM/yyyy");

However, UNDER NO CIRCUMSTANCES should you use this date format in an
international application!!!

The reason is fairly obvious - it's ambiguous...

E.g. what date is this: "04/02/2004"? You may know exactly what date it is
but, depending on where the client lives, it will be seen as either 4th
February or 2nd April.

Use a three-digit month, and you'll never have any ambiguity.
Apr 17 '07 #2
You may want to read up on System.Globalization.DateTimeFormatInfo

e.g.
Dim dtfi As New System.Globalization.DateTimeFormatInfo
dtfi.ShortTimePattern = "M/d/yyyy"
Dim theDate As Date = Convert.ToDateTime(SomeDateString, dtfi)

Kees
"Jon" <Jo*@discussions.microsoft.comwrote in message
news:86**********************************@microsof t.com...
Hello all,

we have an app with works across the globe, and therefore dates are
displayed in a number of formats, such as dd/MM/yyyy (uk) and MM/dd/yyyy
(usa). When our app has it's language set to ENGLISH everything works
fine,
but when it's set to AMERICAN the dates fail as we're trying to cast a
date
such as 16/04/2007 to a US DateTime.

What I need to know is, no matter what culture/language you're in how do
you
cast the dates a date dd/MM/yyyy.

Thanks,

Jon

Apr 17 '07 #3
On Tue, 17 Apr 2007 01:42:01 -0700, Jon wrote:
Hello all,

we have an app with works across the globe, and therefore dates are
displayed in a number of formats, such as dd/MM/yyyy (uk) and MM/dd/yyyy
(usa). When our app has it's language set to ENGLISH everything works fine,
but when it's set to AMERICAN the dates fail as we're trying to cast a date
such as 16/04/2007 to a US DateTime.

What I need to know is, no matter what culture/language you're in how do you
cast the dates a date dd/MM/yyyy.

Thanks,

Jon
You can save a lot of time (and code) by setting the website's culture at
web.config level to en-GB
--
Bits.Bytes
http://bytes.thinkersroom.com
Apr 20 '07 #4
No, you don't want to do that because it is a web application. Instead
prefer a tostring(MM/dd/YYYY) formatter overload after you have the date.
For web applications you absolutely cannot force a web app to live in one
culture. You want to pick up localization off the request object and adjust
the output accordingly.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley
"Rad [Visual C# MVP]" <no****@nospam.comwrote in message
news:1g***************@thinkersroom.com...
On Tue, 17 Apr 2007 01:42:01 -0700, Jon wrote:
>Hello all,

we have an app with works across the globe, and therefore dates are
displayed in a number of formats, such as dd/MM/yyyy (uk) and MM/dd/yyyy
(usa). When our app has it's language set to ENGLISH everything works
fine,
but when it's set to AMERICAN the dates fail as we're trying to cast a
date
such as 16/04/2007 to a US DateTime.

What I need to know is, no matter what culture/language you're in how do
you
cast the dates a date dd/MM/yyyy.

Thanks,

Jon

You can save a lot of time (and code) by setting the website's culture at
web.config level to en-GB
--
Bits.Bytes
http://bytes.thinkersroom.com

Apr 20 '07 #5
"Alvin Bruney [MVP]" <some guy without an email addresswrote in message
news:uN**************@TK2MSFTNGP04.phx.gbl...
No, you don't want to do that because it is a web application. Instead
prefer a tostring(MM/dd/YYYY) formatter overload after you have the date.
What date is 04/02/2007?
Apr 20 '07 #6
That's easy. 4th of February 2007 of course. :-P
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
"Alvin Bruney [MVP]" <some guy without an email addresswrote in message
news:uN**************@TK2MSFTNGP04.phx.gbl...
>No, you don't want to do that because it is a web application. Instead
prefer a tostring(MM/dd/YYYY) formatter overload after you have the date.

What date is 04/02/2007?

Apr 20 '07 #7
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:OI**************@TK2MSFTNGP06.phx.gbl...
That's easy. 4th of February 2007 of course. :-P
No - it's second of April 2007...
Apr 20 '07 #8
Damn. I had a 50/50 chance and I blew it!!!

No wait... I just checked... it is 4th Feb 2007.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:OI**************@TK2MSFTNGP06.phx.gbl...
>That's easy. 4th of February 2007 of course. :-P

No - it's second of April 2007...

Apr 20 '07 #9
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
Damn. I had a 50/50 chance and I blew it!!!

No wait... I just checked... it is 4th Feb 2007.
No - you're still wrong...
Apr 20 '07 #10
We'll have to either agree to disagree or split the difference. That works
out at about 3rd March 2007. Either way, it is 03/03/2007. :-P Can't go much
wrong with that one.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:OC**************@TK2MSFTNGP05.phx.gbl...
"David" <da*****************@revilloc.REMOVETHIS.comwrot e in message
news:OW**************@TK2MSFTNGP06.phx.gbl...
>Damn. I had a 50/50 chance and I blew it!!!

No wait... I just checked... it is 4th Feb 2007.

No - you're still wrong...

Apr 20 '07 #11
On Fri, 20 Apr 2007 07:41:29 -0400, Alvin Bruney [MVP] wrote:
No, you don't want to do that because it is a web application. Instead
prefer a tostring(MM/dd/YYYY) formatter overload after you have the date.
For web applications you absolutely cannot force a web app to live in one
culture. You want to pick up localization off the request object and adjust
the output accordingly.
I think it depends on circumstances. An international application of course
is one thing but if you know your audeince setting a global culture is a
perfectly good workaround that doesn't even require changing your code
--
Bits.Bytes
http://bytes.thinkersroom.com
Apr 22 '07 #12

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

Similar topics

8
by: Riley | last post by:
The date fields being saved by a VB program were being saved as #2003-11-22#. For reasons unknown to me these dates began to be saved as "11/22/2003" All of these dates were made dates with the...
7
by: Alistair | last post by:
diary_date = request.form("diary_date") - (from a populated drop down list) strSQL = "SELECT saz_title, saz_text from saz_details where saz_date =#" & diary_date & "#" a response.write...
5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
2
by: Rachel Suddeth | last post by:
Is there a way to have the non-selectable dates (those before MinDate and after MaxDate) draw differently so my users can see right away what dates aren't allowed? I'm not seeing it... ...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
7
by: evilcowstare via AccessMonster.com | last post by:
Hi, I have searched the forum for answers on this and to be honest as a novice I find it a bit confusing so apologies if it is simple. There are some searches that I want to apply to my database....
2
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.