1 Replies - 945 Views - Last Post: 02 October 2012 - 03:15 AM Rate Topic: -----

#1 lulu79  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 02-October 12

Convert to DataType DateTime but only want the time

Posted 02 October 2012 - 01:32 AM

How can i convert my column with timespan dataType (Eg: 04:04:45 ) to DateTime in HH:mm:ss format (Eg: 04:04:45)?

Currently I can convert the column to datetime (Eg: 10/2/2012 4:04:45 AM) but I only want the time (Eg: 04:04:45 ).

Dim dc1 As DataColumn

            dc1 = New DataColumn("datanew", GetType(DateTime))

            grpDT.Columns.Add(dc1)

            Dim datanew As DataColumn = grpDT.Columns(2)


            For i As Integer = 0 To grpDT.Rows.Count - 1
                grpDT.Rows(i).Item(datanew) = grpDT.Rows(i).Item("DURATION").ToString()
            Next


I store the column in datatable. I want to use the column to create a graph. But i cant use timespan datatype to generate the result since i got the error "Series data points do not support values of type System.TimeSpan only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort. "

Can someone help me please...

Is This A Good Question/Topic? 0
  • +

Replies To: Convert to DataType DateTime but only want the time

#2 November-06  Icon User is offline

  • D.I.C Regular

Reputation: 46
  • View blog
  • Posts: 396
  • Joined: 04-January 11

Re: Convert to DataType DateTime but only want the time

Posted 02 October 2012 - 03:15 AM

Place the format you like in .ToString(). Use...

DateTime.Now.ToString("HH:mm:ss")


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1