Have you ever used the timespan data type? ie: DateTime TimeStart = DateTime.Now; DateTime TimeEnd = DateTime.Now.AddSeconds( 30 );
TimeSpan span = TimeEnd.Subtract (TimeStart); On Fri, Feb 20, 2009 at 12:10 PM, stapes <[email protected]> wrote: > > Hi > > I have a web application written in ASP.NET <http://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 <http://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 > > > >
