Conversion problem with SQL Server 2005???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dbrunellemdil
    New Member
    • Jan 2008
    • 7

    Conversion problem with SQL Server 2005???

    Hi,
    I am currently working on a .Net 2005 program with a SQLServver 2005 as my main database and I have a weird problem with date. When I insert the data in with the dates everything looks fine ( I insert using the date time format like it should)

    Now when I try to search the records I get a really weird problem. It seems that I need to put the dates in my query as Y-D-M format!

    I tried directly in SQL Server Management Studio with a query like this one
    'SELECT * FROM T_Formation WHERE DateFormation >= '2006-12-18' and I get an error. If I do "SELET * FROM T_Formation WHERE DateFormation >= '2006-28-12' However, I get the results just fine.

    In fact, when I use a Simple Store Procedure like SELECT * FROM T_Formation WHERE DateFormation >= @Date I get what I want. However, my query can't be that simple because I have multiple criterion which can be present or not, so I use a variable @Select which I fill with conditions until I have what I need and this is where it stop working.
    Anyone know what to do?
  • dbrunellemdil
    New Member
    • Jan 2008
    • 7

    #2
    Nevermind that. I found a solution to this problem.
    I used the SET DATEFORMAT ymd before executing the statement and it corrected the situation.

    Comment

    Working...