|
-
Sep 11th, 2009, 01:05 AM
#1
Date formatting
A strange problem, this.
If I run the following:
Code:
Msgbox cdate("15 Aug 2009")
in an application on my dev PC, I return a messagebox showing the correct date, 15/08/09.
On a particular different PC, however, this returns a .Net error "Could not cast string to type..." etc.
On the other hand, if I run this:
Code:
Dim mystr As String
Dim mystrarr() As String
mystr = "15/08/2009"
mystrarr = Split(mystr, "/")
Dim mydate As New Date(mystrarr(2), mystrarr(1), mystrarr(0))
MsgBox(Format(mydate, "dd/MM/yy"))
then I return the correct result 15/08/09 on my PC, but 0/15/09 on the other.
If I change the last Format line, however, to read "dd-MMM-yy", then it returns the correct 15-Aug-09 on BOTH PCs.
It looks like it might be something related to the international setttings, American vs UK format for example, which is getting it confused, but these are both exactly the same. They have the same versions of the framework installed.
Is there any different date/time formatting within the .Net framework? I would have expected it to use the local Windows settings. Any other theories as to why the date cast would crash and the formatting doesn't necessarily work properly with the month?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|