Convert Time to Integer
Convert Time to Integer
Convert Time to Integer
Convert Time to Integer
Convert Time to Integer
Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer
Convert Time to Integer Convert Time to Integer
Convert Time to Integer
Go Back  Xtreme Visual Basic Talk > > > Convert Time to Integer


Reply
 
Thread Tools Display Modes
  #1  
Old 10-07-2008, 10:21 AM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default [Resolved] Convert Time to Integer


I am trying to convert a time column in my data set to an integer. Been trying different way but cannot get it to work:

Code:

Code:
Dim ts As New TimeSpan
ts = TimeSpan.Parse(myRow.Item(3))
Dim zDate As New Date(ts.Ticks)
Dim myTime As Integer = Format(zDate, "HHmmss")
Example: If time is 09:35:48 I need to covert it to 093548.

Error: Conversion from type 'TimeSpan' to type 'String' is not valid.

Last edited by snufse; 10-07-2008 at 10:47 AM.
Reply With Quote
  #2  
Old 10-07-2008, 10:47 AM
snufse's Avatar
snufse snufse is offline
Centurion
 
Join Date: Jul 2003
Location: West Palm Beach FL
Posts: 180
Default

Mybe not the right way, but got it working like this:

Code:
Dim ts As New TimeSpan
ts = myRow.Item(3)
Dim zDate As New Date(ts.Ticks)
Dim myTime As Integer = Format(zDate, "HHmmss")
Reply With Quote
  #3  
Old 10-08-2008, 09:05 AM
wayneph's Avatar
waynephConvert Time to Integer wayneph is offline
Web Junkie

Retired Moderator
* Expert *
 
Join Date: Apr 2004
Location: D/FW, Texas, USA
Posts: 8,393
Default

You are aware that if you store it as an integer you loose the leading digits for the hours. You'll have to format it as six digits every time you print it.

Out of curiousity, why would you need an integer value from the Time anyway?
__________________
-- wayne, MSSM Retired
> SELECT * FROM users WHERE clue > 0
0 rows returned
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Convert Time to Integer
Convert Time to Integer
Convert Time to Integer Convert Time to Integer
Convert Time to Integer
Convert Time to Integer
Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer Convert Time to Integer
Convert Time to Integer
Convert Time to Integer
 
Convert Time to Integer
Convert Time to Integer
 
-->