PC Review


Reply
Thread Tools Rate Thread

date format in different system

 
 
jeff
Guest
Posts: n/a
 
      13th Nov 2004
i have written a program with date format as m/d/yyyy

when i deploy it to client's machine, due to the client use d/m/yyyy format
the Select SQL statement return some record wrongly.

how can i fix this problem ? set the user's locale / date format when
program launch and reset it during exit ?

Pls let me know your way to solve it.
many thanks


 
Reply With Quote
 
 
 
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      13th Nov 2004
"jeff" <(E-Mail Removed)> schrieb:
> i have written a program with date format as m/d/yyyy
>
> when i deploy it to client's machine, due to the client use d/m/yyyy

format
> the Select SQL statement return some record wrongly.
>
> how can i fix this problem ? set the user's locale / date format when
> program launch and reset it during exit ?


Use 'DateTime.ParseExact'/'DateTime.ToString' with an explicit format (and
'CultureInfo.InvariantCulture') specified.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      13th Nov 2004
Jeff,

The best thing you can do is absolute not explicitly using date time
formats. By instance not using toString or using Format.

In a normal setting all should be showed in the right way, depending on the
culture setting of the clients computer.

Just my thought,

Cor

"jeff" <(E-Mail Removed)>

>
> when i deploy it to client's machine, due to the client use d/m/yyyy
> format
> the Select SQL statement return some record wrongly.
>
> how can i fix this problem ? set the user's locale / date format when
> program launch and reset it during exit ?
>
> Pls let me know your way to solve it.
> many thanks
>
>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      14th Nov 2004
Jeff,
It sounds like you are using String concatenation to build a Dynamic SQL
statement, where one of the "parameters" is a date.

As you found out this is not advisable for a number of reasons, including
but not limited to:
1: culture settings change, how one machine displays a date may be different
than another
2: quoting of string characters (How do you handle O'Brian as a parameter?)
3: SQL Injection attacks. If you use string concatenation to build an SQL
statement you are opening up a HUGE security risk in your app!

For information on SQL Injection attacks see:
http://msdn.microsoft.com/msdnmag/is...n/default.aspx

I would recommend you use a parameterized query instead, which eliminates
the above problems, and can also lead to faster code. For an example of a
parameterized query see "Avoid Dynamic SQL" in the above article.

Hope this helps
Jay





"jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>i have written a program with date format as m/d/yyyy
>
> when i deploy it to client's machine, due to the client use d/m/yyyy
> format
> the Select SQL statement return some record wrongly.
>
> how can i fix this problem ? set the user's locale / date format when
> program launch and reset it during exit ?
>
> Pls let me know your way to solve it.
> many thanks
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
In VBE, how can I set a date format different than the system date Alpineskier Microsoft Excel Programming 2 11th Mar 2010 06:01 PM
getting the system date format with vba thread Microsoft Access 1 2nd Dec 2008 01:25 PM
System Date Format =?Utf-8?B?QnJhZA==?= Microsoft Access Form Coding 1 28th Jun 2007 09:38 PM
Change System date format =?Utf-8?B?am91ag==?= Microsoft Access Forms 1 24th Nov 2006 12:07 PM
System Date Format Ken Microsoft Windows 2000 Group Policy 3 16th May 2004 12:08 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 AM.