Date Format with VBNET

  • Thread starter Thread starter Bernard Bourée
  • Start date Start date
B

Bernard Bourée

I have some problems with the date formats with VB.NET
Here is my code:

dim dDateF as New DateTime()
dDateF = Today
'Suppose Today = 31/12/2003 format FRANCE
dDatef = Format(dDate, "dd/MM/yy")
'give me 12/31/03 that is the US format !!!???

My regional settings are set to FRANCE (WinXP)
and if I add the following line :
Thread.CurrentThread.CurrentCulture= New CultureInfo("fr-FR")
The result is unchanged.

Someone can help me ?
Thanks
 
Bernard,

Strange that this question, comes seldom and than 2 times in 24 hours.
Sypatico had almost the same problem.

You tell that dDatef what is in the datetime format shows the values in US
datetimesetting.
That is correct, that is the internal datetime that is used. When you set it
to string it becomes in the European format as you use.

I hope this helps?

Cor
 
Cor

Thanks for your reply and sorry for my cross posting, but I'm trying to get
an answer since 3 days without success.

I need a DATE, not a STRING with the French format.
How can I achieve that ?
 
Bernard,

The date is in French format
\\
Public Class Class1
Public Shared Sub Main()
Dim dDateF As New DateTime(Now.Year, 11, Now.Day)
Dim dateF As String = dDateF.ToString 'not displayed however shows
it complete
MessageBox.Show(dDateF.ToString("dd-MM-yy"))
End Sub
End Class
///
I took november because to day it is forever right.

I hope this helps?

Cor
 
Bernard

Again, by everybody is showed #11-10-2004# in the debugger with the sample
above, internally is everywhere the US date used.

Cor
 
Bernard Bourée said:
dim dDateF as New DateTime()
dDateF = Today
'Suppose Today = 31/12/2003 format FRANCE
dDatef = Format(dDate, "dd/MM/yy")
'give me 12/31/03 that is the US format !!!???

My regional settings are set to FRANCE (WinXP)
and if I add the following line :
Thread.CurrentThread.CurrentCulture= New CultureInfo("fr-FR")
The result is unchanged.

\\\
Dim FrenchCulture As New CultureInfo("fr-FR")
Template = _
CreationTime.ToString( _
"dd/MM/yy", _
FrenchCulture.DateTimeFormat _
)
///
 
Cor
I still have a problem since I need to transfer to a COM object a parameter
which type is a date.
So I need to obtain a Date (not a string) with the french format.
Your exemple is nice but MessageBox show a string !

That's why I have tried with CultureInfo("fr-FR", False)
but it didn' worked !

Is there a solution ?
 
Bernard Bourée said:
You code give me a string not a date !
I need a date type.

Formatting will only be done when converting the date to a string. The date
itself does not store any culture information. When viewing a date
variable's value inside the IDE, it will always shown in US date/time
format.
 
Back
Top