Date converting problem
Dear all,
I have an excel macro which retrieves data from SQL server. I have a SQL
statement which combines 3 int fields of a table into a date field :
mySQL = select cast(str(YearField)+'/'+str(monthField)+'/'+str(dayField) as
datetime) as resultDate from myTable
Then I use ADO connection and recordset for retrieving data.
For example:
if YearField = 2006, monthField = 2 , dayField = 23
then the outcome should be 2006-02-23 00:00:00.000
Now the problem comes. When I run the macro on a computer with "Short Date
Format" "M/d/yyyy" in "Control Panel" - "Regional Options", there is no
problem at all. But the date setting in the computer is "d/M/yyyy", the
select statement fails.
It would be not so convenient to check the date setting of every user's
computer. Can anyone suggest a better way to do this? Any better way to do
the conversion in the SQL statement? Thanks a lot!
Ivan
|