LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default 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

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting hijri date to gregorian date Ramil Marbella Excel Discussion (Misc queries) 1 May 5th 21 10:08 AM
Problem Converting date to month in text for use in pivot table Peters Excel Worksheet Functions 2 October 31st 08 11:16 AM
Converting a date to a text field w/o converting it to a julian da LynnMinn Excel Worksheet Functions 2 March 6th 08 03:43 PM
converting date from a textbox to a date format neowok[_17_] Excel Programming 5 February 23rd 04 01:40 PM
Converting a string date into a Excel Date Phillips Excel Programming 0 November 24th 03 08:54 PM


All times are GMT +1. The time now is 10:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"