Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Express Edition and Compact Edition (2005)
 date problem

Author  Topic 

ujjaval
Posting Yak Master

108 Posts

Posted - 2006-09-07 : 01:46:38
I installed SQL Server Express edition on my computer. My computer had Regional settings for Australia since I am from Australia. Now, I copied my database from my development computer to my computer. I also deployed my front-end for the database which I have developed in .NET 2.0. Now, when I run a query on the database through my application, it doesn't accept the Date as it should. Also, I tried to run that in query editor, but it still takes the date format wrong. Like when I say

Select * from DataTable where DOB='9/3/1980',

ideally it should return me the data for ppl whose bdate is 9 March 1980. But it returns me data for ppl whose birthdate is 3 September 1980.

I changed my computer's regional settings to Autralia, Uninstalled SQL Server express and then installed again. But it has got the same problem. Any ideas?

Ujjaval

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-09-07 : 02:25:09
you should try to specify date in universal format. Rather than MMDDYYYY or DDMMYYYY as it is ambiguous


Select * from DataTable where DOB='19800309'


You can also use set dateformat DDMMYYYY dmy to specify the format but it is advisable to use universal format.
EDIT : in red

KH

Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-07 : 02:30:13
SET DATEFORMAT dmy

Select * from DataTable where DOB='9/3/1980'

It's always a good practice to use ISO format, yyyymmdd, when uncertain.




Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -