Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ASP.NET European date VERY WEIRD PROBLEM

Posted on 2002-06-29
5
Medium Priority
?
369 Views
Last Modified: 2012-06-21
I am designing an ASP.net app for UK - so need the date format dd/mm/yyyy.

My development machine is setup for UK in control panel - and so is the registry (in as dd/mm/yyyy).

When I use
System.DateTime.Now.Date.ToString()
it outputs in dd/mm/yyyy format. When I go into sql server enterprise manager - it outputs in dd/mm/yyyy format.

When I attempt to run a ExecuteNonQuery on a sql server database however, it fails unless the date is in US format?!?!!?

So PLEASE if anyone knows why - help!

Firstly is there a quick workaround that will change the System.DateTime.Now.Date.ToString() date to US format - and secondly and more importantly - how can i get the ExecuteNonQuery to take UK date format?

I have been banging my head against a wall for days - any ideas?
0
Comment
Question by:niico
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 22

Expert Comment

by:CJ_S
ID: 7120170
You will also need to set the correct date / language format of SQL Server. Do this in the properties of the SQL Server machine.

Another way to get the correct date format in SQL Server is by using the SET DATEFORMAT.

Example:
SET DATEFORMAT dmy
SELECT GETDATE()

(change SELECT GETDATE() with any query you want)

CJ


0
 
LVL 20

Expert Comment

by:Michel Sakr
ID: 7121183
try the convert function in sql
0
 
LVL 10

Accepted Solution

by:
smegghead earned 312 total points
ID: 7121677
when you pass the SQL string into SQL Server, you should pass it in the format yyyy-mm-dd, this is a locale independant format.
0
 

Author Comment

by:niico
ID: 7122087
hmm some interesting suggestions - i have ended up going for a simple conversion function that converts from uk date format into us date format - as the sql query engine always needs US format i have read.
0
 

Author Comment

by:niico
ID: 7122089
thanks everyone - i guess this is the most useful answer to me!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question