Formatting Date Time Euro style

  • Thread starter Thread starter Steve Peterson
  • Start date Start date
S

Steve Peterson

Hi

Probably a dumb question, but I'm having problems doing this for some
reason. I have a shortdate as datetime American Style (mm/dd/yy). I need to
convert it to a string that is in European format (dd/mm/yy).

I was hoping someone could help me out..

TIA

Steve
 
* "Steve Peterson said:
Probably a dumb question, but I'm having problems doing this for some
reason. I have a shortdate as datetime American Style (mm/dd/yy). I need to
convert it to a string that is in European format (dd/mm/yy).

I didn't know that there is a European date format. In Austria, we use
"dd.mm.yyyy".
 
Hi Steve

You can change how the Date is Displayed by using the Format Function.

Dim MyDate As Date = Now

Dim MyString As String

MyString = Format(MyDate, "dd/MM/yyyy")

MsgBox(MyString)

Make sure that you use capital M's (M) for the Month not lowercase m's (m)
as you may well find it returning Minutes rather than Months.

Hope this helps.

Neil Knobbe

Visual Basic MVP
 
Wow! That's it? Geeez.. I was off on the "CultureInfo" & Iformatter trail.
The Help isn't too helpful (IMHP) on this subject...

Anyway - thnx! - it did the trick

Steve
 
Herfried said:
I didn't know that there is a European date format. In Austria, we
use "dd.mm.yyyy".

And in the Netherlands it's d-m-yyyy.

You can show and parse a date in the format for any culture, by using the
DateTime.ToString()/DateTime.Parse() overloads that take an IFormatProvider
parameter:

Dim USDate As String = "11/25/1981"
Dim NLDate As String
Dim D As Date = Date.Parse(USDate, _
System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))
NLDate = D.ToString("d", _
System.Globalization.CultureInfo.CreateSpecificCulture("nl-NL"))

The value of NLDate will be "25-11-1981" after that.
 
Hi Steve,

You can do a lot with those answers is it not.
(I took the date of tomorrow because 05-05-04 does not show to much)
Dim EuDate As String = _
Now.AddDays(1).ToString("dd-MM-yy")
Dim UsDate As String = _
Now.AddDays(1).ToString("MM-dd-yy")

I hope this helps?

Cor
 
Hi Herfried,
I didn't know that there is a European date format. In Austria, we use
"dd.mm.yyyy".

I thought they use in Austria also the EU format, however I seem to be
wrong.

day minutes year, definitly different from the rest in the EU

Cor
 
Hi Sven,
And in the Netherlands it's d-m-yyyy.

In the netherlanths is not used days minutes year.

We use like the rest in Europe dd-MM-yy and dd-MM-yyyy
while the first was used before and the last after the millenium.
However that last will be everywhere on the world.

When we are writing we use of course as well long as short notations.

Cor
 
Cor said:
Hi Sven,


In the netherlanths is not used days minutes year.

I know that small m is minutes in a format string, but since that wasn't the
solution I was giving him, that wasn't intended to be a real format string.
We use like the rest in Europe dd-MM-yy and dd-MM-yyyy
while the first was used before and the last after the millenium.
However that last will be everywhere on the world.

Who is "we"? In the Netherlands at least, the official date format is
d-M-yyyy, not dd-MM-yyyy. Even the Windows regional settings agree with me
on that. The difference is of course, that today is 5-5-2004, not
05-05-2004.
When we are writing we use of course as well long as short notations.

And the long notation for today is "woensdag 5 mei 2004".

The date format I prefer to use is still ISO: 2004-05-05

Japanese is also nice: ï¼’ï¼ï¼ï¼”年5月5日
Which is also the output from my code if you ask it for culture "ja-JP" with
"D". I wonder if there's some way to make it say å¹³æˆï¼‘6年5月5日 instead? (that's
using the Japanese years, this year is Heisei 16)
 
Dim MyDate As Date = Now

Dim MyString As String

MyString = Format(MyDate, "dd/MM/yyyy")

MsgBox(MyString)

You can also do it even easier (IMO) this way:

MsgBox(MyDate.ToString("dd/MM/yyyy"))
 
* Chris Dunaway said:
You can also do it even easier (IMO) this way:

MsgBox(MyDate.ToString("dd/MM/yyyy"))

Or: 'MsgBox(Now.ToString(...))' ;-).
 
Back
Top