Question : Different SQL datetime fomats between machines cases problems when searching using c#

Hi,

I am having trouble searching for dates is an SQL database application that i am writing
In my copy of the SQL database the format of a datetime field is  yyyy-mm-dd when displayed in SQL Management Studio, however on my customers machine it is displayed as dd/mm/yyyy.

Could someone explain where  the differences come from and what would be the correct format for searching for rows that are between two specific dates when usng strings as search variables

ps My machines runs sqlExpress2008 my customer runs sqlExpress2005

Many Thanks

Answer : Different SQL datetime fomats between machines cases problems when searching using c#

I use the following format in all my project and I don't experiance any problem.
yyyyMMdd HH:mm:ss.fff

lowercase y: Year,
uppercase M: Month,
lowervase d: day
Uppercase H: Hour in 24 hours,
lowercase m: minute
lowercase s: second
lowercase f: fraction (miliseconds)

example:
select * from Users where DefinedTime between '20090101 00:00:00.000' AND '20100331 23:59:59.997'
Random Solutions  
 
programming4us programming4us