Try setting the language of the database (or if possible the SQL
Server instance) to British English rather than 'English' - this
affects how SQL interprets dates. British date format is dd/MM/yyyy
whereas US date format is MM/dd/yyyy

On Feb 20, 5:10 pm, stapes <[email protected]> wrote:
> Hi
>
> I have a web application written in ASP.NET C# and using SQL Server. I
> am trying to select records with a date < a parameter.
>
> In SQL:
>
> @dtDateBefore datetime
>
> SELECT ... WHERE [log].dateTimeLogged < @dtDateBefore
>
> In C#:
>
> System.TimeSpan diff1 = new System.TimeSpan(48, 0, 0);
> System.DateTime today = System.DateTime.Now;
> System.DateTime hrsAgo = today.Subtract(diff1);
> dsOpenJobs.SelectParameters.Add("dtDateBefore",
> TypeCode.DateTime ,hrsAgo.ToString ());
>
> Trouble is, in ASP.NET my DateTime formats are dd/MM/yyyy. In SQL
> server, they seem to be MM/dd/yyyy.
>
> How can I get this to run correctly?
>
> Stapes

Reply via email to