Sql server date question {C#}

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshaycjoshi
    New Member
    • Jan 2007
    • 153

    Sql server date question {C#}

    I am string dates in DateTime format by two methods.

    One in which i use DateTime.Now and other in which i manually create a DateTime object and fill the day,yeay,month etc.

    During debugging DateTime.Now shows
    '2/14/2009 11:28:44 AM'

    And in manualy created DateTime object it shows
    '2/14/0009 11:50:39 AM'

    Both are exactly same ! (some diff due to diff times of degugging)

    But when I use DateTime.Now it works fine and when I use the other it shows this error
    (The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
    The statement has been terminated.)


    WHERE AM I WRONG ????
  • akshaycjoshi
    New Member
    • Jan 2007
    • 153

    #2
    Ok i found where the problem is

    INSERT INTO [CMS].[dbo].[Call_Data]( [Ext_Number],[Trunk_Number],[Cost],[Pin],[Account],[Called_Number],[Duration],[Description],[Call_Date] ) VALUES ('111','1',20,' ',' ','351',2,'Succ ess','2/14/0009 12:01:02 PM' )


    INSERT INTO [CMS].[dbo].[Call_Data]( [Ext_Number],[Trunk_Number],[Cost],[Pin],[Account],[Called_Number],[Duration],[Description],[Call_Date] ) VALUES ('111','1',20,' ',' ','351',2,'Succ ess','2/14/2009 12:06:40 PM' )

    See the bold date part.
    When i fill it to datetime it gets filled as 00009.
    I fill it as argument in DateTime Constructor (...,09,...)
    How to solve this ?
    How would i solve this ?

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Read this and this


      -- CK

      Comment

      Working...