Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Date translation Question

Status
Not open for further replies.

TomGuy

Programmer
Jun 25, 2002
24
CA
Hi there,

I have a french date in the format of "dd mmmm yyyy" or "09 mai 2002" and I need to turn it into the format "yymmdd" or "020509" Is there a way I can do this using my English version of Visual Basic? I tried using the format function but since the date is in french, it doesn't recognize it...

Any help appreciated....

Thanks,

Tom
 
You will need to make it English.
Try using the Replace function e.g.

Code:
Private Function FRDateToEN(DateString As String) As String
Dim S As String
S = DateString
S = Replace(S, "FEV", "FEB", , , vbDatabaseCompare)
S = Replace(S, "MAI", "MAY", , , vbDatabaseCompare)
'etc
FRDateToEN = S
End Function
 
Try setting your system's country setting to French.
 
You have to convert the date to a string. You can break the string in pieces with the Mid function. When you have, for example a string like #27-06-02# (put in a variable) and your app needs input like #06-27-02# then you isolate the day and month with mid(variablename, 2, 2) and mid (variablename, 5, 2) Then you concatenate the month with the day, put dashes between it, and you've got the right format.
 
Ah! But with a 2-digit day & month, which is which? (Which is the root of several similar posts) US or UK (or other) format?

Going back to the original question, it may be an idea to write a function that translates French months - and as they are mmmm months they will be full length.

e.g.
Code:
Public Function FRMonthNum(MonthStr As String) As Integer
Select UCase$(MonthStr)
Case "JANVIER": FRMonthNum = 1
Case "FÉVRIER": FRMonthNum = 2
Case "MARS": FRMonthNum = 3
etc.
End Select
End Function

... then use string parsing as suggested by gransbpa, but don't rely on absolute positions - look for the spaces (format is 'dd mmmm yyyy')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top