Difference between two varchar columns

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mzmishra
    Recognized Expert Contributor
    • Aug 2007
    • 390

    Difference between two varchar columns

    Hi,

    I have two columns in datagrid which are of type varchar in database .These two columns stores start time and end time value.Now I want to have one column which will store the difference between start and end time.
    How to do that. For example my start time stores 09:20 and and time value is 09:30 ,but these are two varchar fields in database.
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Originally posted by mzmishra
    Hi,

    I have two columns in datagrid which are of type varchar in database .These two columns stores start time and end time value.Now I want to have one column which will store the difference between start and end time.
    How to do that. For example my start time stores 09:20 and and time value is 09:30 ,but these are two varchar fields in database.
    the time differences can be found using timespan

    Comment

    • mzmishra
      Recognized Expert Contributor
      • Aug 2007
      • 390

      #3
      Originally posted by Shashi Sadasivan
      the time differences can be found using timespan
      Hi,

      Can you please send some code samples how to do that?
      Thanks.

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        Originally posted by mzmishra
        Hi,

        Can you please send some code samples how to do that?
        Thanks.

        Code:
        DateTime dt1 = DateTime.Now;
        DateTime dt2 = DateTime.Now;
        TimeSpan ts = new TimeSpan();
        ts = dt2.Subtract(dt1);
        That Should get you going.

        Cheers

        Comment

        Working...