10-03-2005 05:57 AM
10-05-2005 10:14 AM
Hi Gurdas,
From your post, I guess you use "Format Date/Time String" vi to format a time stamp into a string.
Did you try to use "DB Tools Format Datetime Str" vi to convert the time stamp into a string?
Xu
10-05-2005 11:37 AM
Hi Xu,
Thanks for the reply.
I did consider using the "DB Tools Format Datetime Str" string but stopped because of two reasons:
1) I was not convinced it will give any advantage because what we were doing seemed logically correct
2) The number of places where we need to implement the change is high.
But if we are convinced it will help, there will not be any hesitation to implement.
What do you feel? Or maybe we can try the change in a small part of the code and then go for a full change?
Warm wishes,
Gurdas
10-05-2005 12:24 PM - edited 10-05-2005 12:24 PM
Message Edited by Dynamik on 10-05-2005 12:25 PM
Message Edited by Dynamik on 10-05-2005 12:27 PM
10-05-2005 01:42 PM
10-05-2005 01:47 PM
10-06-2005 10:40 AM
Hi Dynamik,
Thanks for your reply. I have put in a more detailed reply below (in answer to Xu's idea).
- Gurdas
10-06-2005 10:55 AM
Hi Xu,
You answer led me to some very interesting fact finding on how SQL server handles date and time. I have attached a zip file which contains webpages that throw more light on this issue.
The attached pages tell me that SQL has an inbuilt date/time reference format. The default in mm/dd/yyyy. Which explains why my VI worked when I used that format to write to SQL.
However there is a catch:
SQL expects the date/time to be in its inbuilt reference format when you WRITE data to SQL. If the date/time is in a different format, better tell SQL about it by using say the SET command you mentioned.
BUT what about the date/time format when you are reading data from SQL?
Our finding is that SQL sends date/time string in the system date format when you READ from SQL !!! That is very surprising behaviour (why differentiate between write and read?).
Is our finding correct?
So, we adopted the following simple strategy (yet to be fully tested):
1) Whenever we write date/time to SQL, the string is formatted as mm/dd/yyyy. Presently, the user's SQL server is in the default state. Caveat is that if the user changes SQL date/time from default (which is mm/dd/yyyy) to anything else, our software will give errors. But then he changed it 😉
2) When we read date/time from SQL we format the string as per system date/time format.
I know this is not very robust coding. But assuming the user keeps his SQL in the current setting, should we expect smooth working?
In other words, are there any errors and/or flaws in our strategy?
Thanks,
Gurdas
10-06-2005 10:59 AM
Sorry, forgot to attach the zip file in my previous post .....
10-06-2005 12:59 PM
Hi Gurdas,
Your solution should smoothly works, though is not very robust coding said (when your user change the SQL date format settings).
My suggestion is to format the date as yyyy-mm-dd (if it does not work, format to yyyymmdd). This will be independent on the SQL settings (more robust). You can use "DB Tools Format Datetime Str" vi (triming extra stuff), or other ways.
Good luck,
Xu