Solved

ASP.NET European date VERY WEIRD PROBLEM

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

740 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