D
Darin
I have an applicatoin that works 100% perfect when running on a machine
setup for English (United States), but when I change it to Spanish
(Mexico), the dates start giving me fits.
THe reason is USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the
computer set to mexico, any standard CDATE function is going to return
the date in the dd/mm/yyyy setting since that is what the computer is
set to.
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.
I wrote a routine that changed the order to get it in the format, but it
is a string. When I then try to change it to a date, the Cdate routine
either changes the format or errors because it is trying to change the
format.
Dim junk As Date
Dim sjunk As String
junk = #1/1/1901#
Try
If Not IsDBNull(in_object) Then
sjunk = DRStr(in_object)
If
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern <>
"M/d/yyyy" Then
' not USA
Dim xpattern As String
xpattern =
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern
If Mid(xpattern, 1, 1) = "d" Then
' day is first
Dim ddate As String
Dim xflds() As String
xflds = Split(DRStr(sjunk), "/")
ddate = xflds(1) & "/" & xflds(0) & "/" & xflds(2)
sjunk = ddate
End If
End If
junk = CDate(sjunk)
Else
junk = CDate(in_object)
End If
Catch oExcept As Exception
'ShowMessage(oExcept.Message)
End Try
Return junk
The statement junk=cdate(sjunk) is what is changing the date back into
the global settings on the comptuer.
Any help would be greatly appreciated. I really wish CDate would allow
me to have an argument as the globalization settings allowing me to
force what setting I want the date to be. Don't forget, the FORMAT
command returns a string, not a date.
Thanks in advance.
Darin
setup for English (United States), but when I change it to Spanish
(Mexico), the dates start giving me fits.
THe reason is USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the
computer set to mexico, any standard CDATE function is going to return
the date in the dd/mm/yyyy setting since that is what the computer is
set to.
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.
I wrote a routine that changed the order to get it in the format, but it
is a string. When I then try to change it to a date, the Cdate routine
either changes the format or errors because it is trying to change the
format.
Dim junk As Date
Dim sjunk As String
junk = #1/1/1901#
Try
If Not IsDBNull(in_object) Then
sjunk = DRStr(in_object)
If
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern <>
"M/d/yyyy" Then
' not USA
Dim xpattern As String
xpattern =
System.Globalization.DateTimeFormatInfo.CurrentInfo.ShortDatePattern
If Mid(xpattern, 1, 1) = "d" Then
' day is first
Dim ddate As String
Dim xflds() As String
xflds = Split(DRStr(sjunk), "/")
ddate = xflds(1) & "/" & xflds(0) & "/" & xflds(2)
sjunk = ddate
End If
End If
junk = CDate(sjunk)
Else
junk = CDate(in_object)
End If
Catch oExcept As Exception
'ShowMessage(oExcept.Message)
End Try
Return junk
The statement junk=cdate(sjunk) is what is changing the date back into
the global settings on the comptuer.
Any help would be greatly appreciated. I really wish CDate would allow
me to have an argument as the globalization settings allowing me to
force what setting I want the date to be. Don't forget, the FORMAT
command returns a string, not a date.
Thanks in advance.
Darin