Solved

ASP.NET European date VERY WEIRD PROBLEM

Posted on 2002-06-29
5
360 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
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:Silvers5
ID: 7121183
try the convert function in sql
0
 
LVL 10

Accepted Solution

by:
smegghead earned 78 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now