date from different countries

  • Thread starter Thread starter Darin
  • Start date Start date
Martin,

Just reading what the OP wrote in his first message gives in my idea answer
on what you wrote.
I want to be able to enter a date in dd/mm/yyyy format but return a true
date, but in the format mm/dd/yyyy, similar to CDate. I don't want a
string, I want a real date.

And more of that where he shows to have the opinion that a "real date is"
#MM-dd-yyyy" as the debugger and the intelisence from VB.Net returns it. If
he would had used C# he could have seen that this is only a VB.Net
debugger/intelisence format.

Cor
 
Martin,
No, the simplification won't work, because the OP wrote that he wants to
have the US date. The US date has slashes in it (e.g. 01/31/2007).
I missed the US date specifically , I only saw m/d/y format.
However, the format command will replace the slashes with the separators
for your country. In my case (Germany) we use dots. With the simplified
Good point, in that case I would include the / literally and not as the date
separator:

Private Function BASICdate(byval ThisDate As Date) As String
Return ThisDate.ToString("MM\/dd\/yyyy")
End Function

http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx

To get the real BASIC date the best option is to assemble the string as I
did before.
I tend to feel its safer to let a type itself handle its own formatting
rather the presume I know how to format it.

IMHO Letting DateTime format itself *is* the only option! Especially when
DateTime custom formatting fully supports it!

BTW: Thank you for identifing a potential "gotcha" in custom formatting!
 
Back
Top