5 Replies - 234 Views - Last Post: 06 May 2019 - 06:23 PM Rate Topic: -----

#1 pjfatboy1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 27-February 16

Time Format Question

Posted 05 May 2019 - 12:00 PM

When finding the time span between to strings, like 7:00 am from 12:00 pm, would that be converted to a TimeSpan or Date Diff? I'm trying TimeSpan but I get an error "String was not recognized as a valid TimeSpan. I know that should give me a clue but I want to make sure before spending the time changing my code. Thank....
Is This A Good Question/Topic? 0
  • +

Replies To: Time Format Question

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: Time Format Question

Posted 05 May 2019 - 12:48 PM

What's your code look like?
Was This Post Helpful? 0
  • +
  • -

#3 pjfatboy1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 27-February 16

Re: Time Format Question

Posted 05 May 2019 - 03:08 PM

Dim dt1 As TimeSpan
Dim dt2 As TimeSpan
Dim tTI As TimeSpan
Dim tBO As TimeSpan
Dim tBI As TimeSpan
Dim tTO As TimeSpan
Dim tTime As TimeSpan

tTI = TimeSpan.Parse(Format(lbStart.Text, "HH:mm:ss tt")) 'Error is here
tBO = TimeSpan.Parse(Format(lbBO, "HH:mm:ss tt"))
dt1 = tBO - tTI
tBI = TimeSpan.Parse(Format(.Rows(i).Cells(5).Value, "HH:mm:ss tt"))
tTO = TimeSpan.Parse(Format(.Rows(i).Cells(6).Value, "HH:mm:ss tt"))
dt2 = tTO - tBI

tTime = dt2 - dt1

If tTime.Hours <= 0 Then
     tTime = (tTime + New TimeSpan(0, 24, 0, 0, 0))
End If


This post has been edited by pjfatboy1: 05 May 2019 - 03:10 PM

Was This Post Helpful? 0
  • +
  • -

#4 Sheepings   User is offline

  • Senior Programmer
  • member icon

Reputation: 223
  • View blog
  • Posts: 1,260
  • Joined: 05-December 13

Re: Time Format Question

Posted 05 May 2019 - 06:33 PM

https://docs.microso...etframework-4.8
Was This Post Helpful? 0
  • +
  • -

#5 dbasnett   User is offline

  • D.I.C Addict
  • member icon

Reputation: 122
  • View blog
  • Posts: 679
  • Joined: 01-October 08

Re: Time Format Question

Posted 06 May 2019 - 06:02 AM

I don't think timespans take AM/PM designation.
Was This Post Helpful? 0
  • +
  • -

#6 pjfatboy1   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 22
  • Joined: 27-February 16

Re: Time Format Question

Posted 06 May 2019 - 06:23 PM

I fixed the problem, I added a date and changed from TimeSpan to DateTime and got the answer using DateDiff. Thanks for the hint dbasnett

This post has been edited by pjfatboy1: 06 May 2019 - 06:24 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1