views:

90

answers:

3

I use sql server 2008 R2 as a data store.

Until now on the test machine I had the english version of the software and used to make queries formatting the datetime field as

fromDate.ToString("MM/dd/yyyy");

now I have deployed the database on another server which is in the italian language. I shall change the format in my code to

fromDate.ToString("dd/MM/yyyy");

Is there a way to make the query in a neutral format?

thanks!

EDIT:

I forgot to mention that I am using NetTiers with CodeSmith. Here's a complete sample

AppointmentQuery aq = new AppointmentQuery(true, true);
aq.AppendGreaterThan(AppointmentColumn.AppointmentDate, fromDate.ToString("MM/dd/yyyy"));
aq.AppendLessThan(AppointmentColumn.AppointmentDate, toDate.ToString("MM/dd/yyyy"));
AppointmentService aSvc = new AppointmentService();
TList<Appointment> appointmentsList = aSvc.Find(aq);
+1  A: 

Personally, I always use yyyy-MM-dd. This also makes it sortable as a string.

However, a date is a date is a date. There's no need to change the date to a string. In .NET, user DateTime.

Brad
+3  A: 
Chris Taylor
@Chris Taylor: no I am not using string concats. Please see my edit for more details. I have forgotten to mention that I was using the Strong typed query objects from NetTiers. thanks
Lorenzo
@Lorenzo, I updated my response to address the new info you provided in your question, but this has taken the question into a technology I have not worked with take what I say here with a grain of salt.
Chris Taylor
@Chris Taylor: No Chris I cannot pass to the various append methods date instances because they only accept string parameters. :)
Lorenzo
+1  A: 
ProfK