Time difference

Results 1 to 4 of 4

Thread: Time difference

  1. #1
    Join Date
    Dec 1969

    Default Time difference

    Hi all!<BR>I need to know the time (hour and minutes) between 2 different given times, parsed into a string. For example:<BR><BR>Startwork: 07:00, endwork: 16.00 i need to know how many hours the person worked (16.00 - 07.00= ??.??). is there an equivalent to asp DATEDIFF for time functions? Whats the easiest way to do this?<BR>Thanks in advance.<BR>Anders<BR>

  2. #2
    Michal M Guest

    Default RE: Time difference

    Hej Anders,<BR>I do not know of a built in function but I think you could write a function yourself. Here is what I was able to come up with:<BR>&#060;%<BR>Function TimeDiff(strTimeOne,strTimeTwo)<BR>Dim intTimeOne,intTimeTwo<BR> intTimeOne = CInt(Left(strTimeOne,2))<BR> intTimeTwo = CInt(Left(strTimeTwo,2))<BR> TimeDiff = intTimeTwo - intTimeOne<BR>End Function<BR>%&#062;<BR>This will work, but you should probably add some error checking (for invalid input) and you might want to do something with minutes as well (this version just ignores them)<BR>Hope this helps,<BR>Michal M

  3. #3
    balletchick Guest

    Default RE: Time difference

    If you would RTFM, you would see that DATEDIFF works for TIME, as well. :)<BR><BR>Look at:<BR><BR>http://help.activeserverpages.com/iishelp/VBScript/htm/vbs93.htm<BR><BR>

  4. #4
    Join Date
    Dec 1969

    Default RE: Time difference


Posting Permissions

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