Results 1 to 4 of 4

Thread: Subtracting time

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    1
    Hi, I'm new to VB--I would like to know how to subtract between time periods i.e. In 8:35am Out 11:40am and I would have to do this for at least 5 different times in one day (Employee Time Sheet).

    Any help would be greatly appreciated thanks,

    JT

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I would convert it all to minutes, do the subtraction, and then back to hours
    NXSupport - Your one-stop source for computer help

  3. #3
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    The datediff function returns the difference between to dates in specified time intervals

    difference = DateDiff(interval, date1, date2)

    where interval can be:
    Code:
    yyyy	Year
    q	Quarter
    m	Month
    y	Day of year
    d	Day
    w	Weekday
    ww	Week
    h	Hour
    n	Minute
    s	Second
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  4. #4
    Addicted Member
    Join Date
    Feb 2001
    Posts
    198
    Be careful with datediff:

    It will return 1 day, one hour or one minute between 1 second to midnight and one second after midnight.

    If this period extends over 31st December - 1st January then datediff returns one year, although if you ask for the result in seconds the result is two seconds as expected.

    It all depends on the size of the interval.

    On a timesheet, asking for the result in hours, you may credit someone with one hour for two minutes work.

    I would agree with dimava - calculate in minutes then convert it back.

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