2 Replies - 23549 Views - Last Post: 08 February 2011 - 06:00 PM Rate Topic: -----

#1 Essel   User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 118
  • Joined: 08-May 09

Difference between two times

Posted 08 February 2011 - 05:08 PM

Please i have this problem trying to get the time difference between a clockintime and a clockout time.The problem is i want to display to the user the total difference of his/her clock in time.Like if the person cloked in at 8:00:00 Am and clocked out at 9:00:00 am i should get 1 hour as the difference but what i get from my code is the 1 hr and also 60 min which is still that same 1 hour.It look correct but this not how i want it to appear.What i want is if it is 1 hour it should just write 1 hour 0 min 0 sec and not 1 hour, 60 min and .... secs no.i want it as a whole number spliting it in appropriate dimensions like eg: if the clock in time is 8:00 am and Clock out time is 9:20 am it should write 1 hour,20 min.
This is the code am using
TimeDiffH = (DateDiff(DateInterval.Hour, CDate(ClockInTime), CDate(ClockOutTime)))
            TimeDiffM = (DateDiff(DateInterval.Minute, CDate(ClockInTime), CDate(ClockOutTime)))
            TimeDiffS = (DateDiff(DateInterval.Second, CDate(ClockInTime), CDate(ClockOutTime)))

Please help me
Thank you

Is This A Good Question/Topic? 0
  • +

Replies To: Difference between two times

#2 smohd   User is offline

  • Critical Section
  • member icon


Reputation: 1825
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Difference between two times

Posted 08 February 2011 - 05:20 PM

The question is answered here
If you get helped dont forget + sign down here
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008   User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • Posts: 9,535
  • Joined: 29-May 08

Re: Difference between two times

Posted 08 February 2011 - 06:00 PM

If you're casting CDate(ClockInTime)to a Date Type.
You could just subtract one from the other.

Dim PeriodOfTimeBetweenThem As TimeSpan = Date2 - Date1

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1