Results 1 to 2 of 2

Thread: time diff

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    time diff

    Hi

    I am using 24hours time format. And able to retrive the working hours and minutes within the time schedule from 1 am to 24 pm but if the shift start from 20 hrs to 6 am than unable to calculate the time ..


    Code:
    Dim TotalHours As Double
         Dim TotalMinutes As Double
         TotalMinutes = DateDiff(DateInterval.Minute, CDate(txtShiftFrom.Text), CDate(txtShiftto.Text))
         TotalHours = Math.Round(TotalMinutes / 60, 0)
         txtTotalWorkingHours.Text = TotalHours
         txtMinutes.Text = TotalMinutes
    Pls help how solve the problem

  2. #2
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Re: time diff

    Code:
            Dim date1 As New System.DateTime(2007, 3, 1, 20, 1, 0)
            Dim date2 As New System.DateTime(2007, 3, 2, 6, 0, 0)
    
            Dim diff1 As System.TimeSpan
            ' 20:01 - 06:00
            ' diff1 gets 9 hours, and 58 minutes.
            diff1 = date2.Subtract(date1)
    
            Debug.Print("TotalHours " & diff1.Hours)
            Debug.Print("TotalMinutes " & diff1.Minutes)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width