Wer
Guest
Posts: n/a

 01-31-2005
Hi,

I'm trying to add hours together in the format HH:MM + HH:MM. There
doesn't seem to be a functional part of DateAdd that will accomplish
this though ?

The calculation is to work out how many hours have been spent on a
website so exceeding the 24:00 is fine.
Is there another function that would accomplish this ?

Thanks

W.

Bob Barrows [MVP]
Guest
Posts: n/a

 01-31-2005
Wer wrote:
> Hi,
>
> I'm trying to add hours together in the format HH:MM + HH:MM. There
> doesn't seem to be a functional part of DateAdd that will accomplish
> this though ?
>
> The calculation is to work out how many hours have been spent on a
> website so exceeding the 24:00 is fine.
> Is there another function that would accomplish this ?
>
> Thanks
>
> W.

Use DATEPART to convert the datetime values to the appropriate resolution
and simply add them together arithmetically. You will need to create a
function to display the results in hh:mm format if that is required, because
that ability is not builtin. Google should provide many examples of doing
this. I would search for

vbscript format time duration hh:mm

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Ray Costanzo [MVP]
Guest
Posts: n/a

 01-31-2005
How would it know if you go from 13:50 to 14:50 that you mean 1 hour, 25
hours, 49 hours, etc.? You have to include a date to avoid this ambiguity.

Ray at work

"Wer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> I'm trying to add hours together in the format HH:MM + HH:MM. There
> doesn't seem to be a functional part of DateAdd that will accomplish
> this though ?
>
> The calculation is to work out how many hours have been spent on a
> website so exceeding the 24:00 is fine.
> Is there another function that would accomplish this ?
>
> Thanks
>
> W.
>

Evertjan.
Guest
Posts: n/a

 01-31-2005
Wer wrote on 31 jan 2005 in microsoft.public.inetserver.asp.general:

> I'm trying to add hours together in the format HH:MM + HH:MM. There
> doesn't seem to be a functional part of DateAdd that will accomplish
> this though ?

Could be don but I prefer the hands on way below.

> The calculation is to work out how many hours have been spent on a
> website so exceeding the 24:00 is fine.
> Is there another function that would accomplish this ?

Using vbscript:

time1 = "13:17"
time2 = "12:51"

time1a = split(time1,":")
time2a = split(time2,":")

mi = 1*time1a(1) + 1*time2a(1)
hr = 1*time1a(0) + 1*time2a(0)

if mi>59 then mi = mi-60 : hr = hr+1

response.write hr & ":" & two(mi) ' writes 26:08

function two(x)
if x<10 then x = "0" & x
two = x
end function

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Evertjan.
Guest
Posts: n/a

 01-31-2005
Ray Costanzo [MVP] wrote on 31 jan 2005 in
microsoft.public.inetserver.asp.general:
> "Wer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> Hi,
>>
>> I'm trying to add hours together in the format HH:MM + HH:MM. There
>> doesn't seem to be a functional part of DateAdd that will accomplish
>> this though ?

> How would it know if you go from 13:50 to 14:50 that you mean 1 hour,
> 25 hours, 49 hours, etc.? You have to include a date to avoid this
> ambiguity.

Not the difference, Ray, but the sum was asked for.

They are just amounts of time to be added.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Ray Costanzo [MVP]
Guest
Posts: n/a

 01-31-2005

Ray at work

"Evertjan." <(E-Mail Removed)> wrote in message
news:Xns95EFA4A798E3Deejj99@194.109.133.29...

> Not the difference, Ray, but the sum was asked for.
>
> They are just amounts of time to be added.
>
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)
>

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mel ASP .Net 1 11-07-2008 08:20 PM Øyvind Isaksen ASP General 4 10-18-2003 01:43 PM Tipple ASP General 2 10-16-2003 03:57 PM Matt Tapia ASP .Net 1 08-13-2003 02:18 PM lofty ASP General 5 07-20-2003 12:33 PM