siddhartha
Member
- Joined
- Jan 6, 2010
- Messages
- 6
- Programming Experience
- 10+
Using OLE and Jet, you may receive errors when saving system dates and times to databases in different regions.
Consider what happens when saving dates and times returned using the Now() function in Canada or the US: the date string "#2010/02/03 08:59 AM#" will save fine. If using 24 hour time, the string "#2010/02/03 08:59#" will also save fine.
If you change your system region to Spanish (Peru) or Spanish (Mexico), the ante meridiem changes from "AM" to "a.m." (or "p.m."). The date string becomes: "#2010/02/03 08:59 a.m.#"
Note that this will NOT save correctly to the database and throw a System.Data.OleDb.OleDbException. The workaround we use is:
Consider what happens when saving dates and times returned using the Now() function in Canada or the US: the date string "#2010/02/03 08:59 AM#" will save fine. If using 24 hour time, the string "#2010/02/03 08:59#" will also save fine.
If you change your system region to Spanish (Peru) or Spanish (Mexico), the ante meridiem changes from "AM" to "a.m." (or "p.m."). The date string becomes: "#2010/02/03 08:59 a.m.#"
Note that this will NOT save correctly to the database and throw a System.Data.OleDb.OleDbException. The workaround we use is:
VB.NET:
Public Function clean_date(ByVal strDate As String) As String
Dim str_buffer As String
str_buffer = strDate
str_buffer = Replace(str_buffer, "a.m.", "AM")
str_buffer = Replace(str_buffer, "p.m.", "PM")
str_buffer = Replace(str_buffer, "A.M.", "AM")
str_buffer = Replace(str_buffer, "P.M.", "PM")
Return str_buffer
End Function