473,789 Members | 2,703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1915
"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.Parse Exact'/'DateTime.ToStr ing' with an explicit format (and
'CultureInfo.In variantCulture' ) 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.Parse Exact'/'DateTime.ToStr ing' with an explicit format (and
'CultureInfo.In variantCulture' ) 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******** ******@TK2MSFTN GP15.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
14882
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 CCYYMMDD. Sounds easy enough, right?? I am attempting to accomplish this by creating a GregorianCalender which will get me the week of year. Then by changing the day of week to 1 (start of week) i'm trying the get the first day of the week,...
2
702
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 versa. I tried regional setting of my XP Professional Machine from US to UK and chenged dateformat but when I tried to print date using asp its giving same unchaged previous format even after restarting the machine.
3
2810
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 with the appropriate date but how do I handle different regional settings for short date, such as: month / day / full year
6
3298
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 PC with let's say ddmmyyyy windows date format and the client has mmddyyyy. when the filter expression send is "Date < #31/01/2003#", it will fail on
4
763
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
35638
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 project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
8
4429
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" (With seconds listed in the report field). However, nobody wants to see the seconds. So I tried to format it =Format(DateCollected, "mm/dd/yy hh:nn AM/PM"). Works great, right? Well.. yeah for the most part. However if we
17
5286
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
3389
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 USA is mm/dd/yyyy and mexico is dd/mm/yyyy. So, with the computer set to mexico, any standard CDATE function is going to return the date in the dd/mm/yyyy setting since that is what the computer is set to. I want to be able to enter a date in...
3
3201
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 m/d/yyyy while in my Regional Settings, I have defined the format as dd/MM/yyyy. If I run the same Application on my Laptop with Windows XP Pro, it displays the correct date format, any idea please ? Best Regards,
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10410
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9984
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.