Solved

ASP.NET European date VERY WEIRD PROBLEM

Posted on 2002-06-29
5
358 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Setting location of a form 4 22
Paging GridView 7 34
C# DataGridView_RowsAdded event not firing 1 38
Showdialog 8 20
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.   …
It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

20 Experts available now in Live!

Get 1:1 Help Now