473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

date format in different system

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
Nov 21 '05 #1
5 1881
"jeff" <ir******@yahoo.com> 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/>
Nov 21 '05 #2
"jeff" <ir******@yahoo.com> 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/>
Nov 21 '05 #3
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" <ir******@yahoo.com>

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

Nov 21 '05 #4
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" <ir******@yahoo.com>

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

Nov 21 '05 #5
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" <ir******@yahoo.com> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
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

Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: cg_news | last post by:
In short, what I am trying to do is, based on a date, calculate the week of year (as described in ISO 8601), then calculate the first and last date in this week period and return them in the format...
2
by: F | last post by:
Hi All I am facing the most common problem of date where system date is different and SQL server dateformat is different. How I can change Date fomat in SQL server from US to UK format vis...
3
by: Andrew Poulos | last post by:
I'm updating a db in which I have a column of Date/Time data type. The regional settings here for short date are: day / month / full year eg. 28/4/2005 It's easy enough for me to build a string...
6
by: Willie wjb | last post by:
Hi, i have a client program that sends a filter expression to the server PC. On that server PC this filter is put over a datatable and the result is send back. the server can be located on a...
4
by: franco | last post by:
I am a beginner in programming. How can I display the system date - 5 December 2005 in my webpage.
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
8
by: Ryan | last post by:
Hello, I'm new to Access and DB's in general. I've taken over some light duty support for a lab information system we use in house. Most of our dates are reported as "10/31/2006 12:30:00 PM"...
17
by: Petyr David | last post by:
Just looking for the simplest. right now my perl script returns an error messge to the user if the date string is invalid. would like to do this before accessing the server. TX
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
3
by: Luqman | last post by:
I have deployed my ASP.Net Application on Windows Server 2000, Service Pack 4, when I run my Application and shows today's date with system.date.today.ToShortDateString, it shows in the format...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.