OLEDB + Date [modified]
-
Hi everyone, I am using OLEDB APIs (such as CTable, CDynamicAccessor etc) for retrieving data from a text file (say abc.txt). The problem is while retrieving date value. When date in "Regional and Language Options in Control Panel" is "M/d/yyyy" format, GetValue of CDynamicAccessor returns correct date value. If i change date format to "d/M/yyyy", GetValue returns NULL. Can anyone tell me the reason for this behaviour? Thanks -- modified at 3:17 Monday 9th July, 2007
-
Hi everyone, I am using OLEDB APIs (such as CTable, CDynamicAccessor etc) for retrieving data from a text file (say abc.txt). The problem is while retrieving date value. When date in "Regional and Language Options in Control Panel" is "M/d/yyyy" format, GetValue of CDynamicAccessor returns correct date value. If i change date format to "d/M/yyyy", GetValue returns NULL. Can anyone tell me the reason for this behaviour? Thanks -- modified at 3:17 Monday 9th July, 2007
What format is the date value inside the text file? The problem recognising D/M/Y versus M/D/Y is that there are a large number of values (where both M and D are <= 12) where it cannot be categorically determined which format is in use. If the data driver you are using is expecting M/d/yyyy, then in theory you could call SetThreadLocale() while you do the retrieval, and set it back again afterwards, but there's no guarantee that it isn't using LOCALE_SYSTEM_DEFAULT or LOCALE_USER_DEFAULT, rather than calling GetThreadLocale() internally.
Steve S Developer for hire
-
What format is the date value inside the text file? The problem recognising D/M/Y versus M/D/Y is that there are a large number of values (where both M and D are <= 12) where it cannot be categorically determined which format is in use. If the data driver you are using is expecting M/d/yyyy, then in theory you could call SetThreadLocale() while you do the retrieval, and set it back again afterwards, but there's no guarantee that it isn't using LOCALE_SYSTEM_DEFAULT or LOCALE_USER_DEFAULT, rather than calling GetThreadLocale() internally.
Steve S Developer for hire