473,396 Members | 1,765 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DateAdd

Wer
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.

Jul 22 '05 #1
5 1408
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.
Jul 22 '05 #2
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" <we*@tlcevents.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr 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.

Jul 22 '05 #3
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)

Jul 22 '05 #4
Ray Costanzo [MVP] wrote on 31 jan 2005 in
microsoft.public.inetserver.asp.general:
"Wer" <we*@tlcevents.co.uk> wrote in message
news:11**********************@f14g2000cwb.googlegr 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)

Jul 22 '05 #5
My bad. :]

Ray at work

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@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)

Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lofty | last post by:
Dear Lord, I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days. <% for i = -7 to -1 Response.write...
4
by: Øyvind Isaksen | last post by:
Hi! I need to add 1 day to a specific date. The date have is stored in a variable called "DateOld". The value of the variable have this syntax: mm.dd.yyyy. The new date is the variable called...
9
by: Brandon | last post by:
Greetings, I am having a problem getting a SQL statement that is functional in Access 2K to work in ASP. My Access SQL statement is this: SELECT DateAdd('s',Ticket_Opened_Date,'Dec 31, 1969...
0
by: Zlatko Matiæ | last post by:
I am currently migrating from MSDE to PostgreSQL and have to rewrite the function that is calculating next date of sampling... In MSDE there is a DateAdd function. I can't find the appropriate...
1
by: Raghu | last post by:
Hello... I am running into a problem while running a query..can some1 help.. this is the query : ************** SELECT * from Table S where S.dtDate1 BETWEEN...
2
by: Abdul N K | last post by:
I need help in T-SQL. I am using DATEADD function and I want to add 6 months to a date. But it does not return me the rusults, which I want e.g. SELECT DATEADD(m,'20040630') returns 20041230...
3
by: Annette Massie | last post by:
I am trying to insert a record into a table via code and one of the values to add I would like as a dateadd calculation on a value from a query. My code looks like this: Set db = CurrentDb() ...
4
by: ey.markov | last post by:
Greetings, I have an A2K application where for a report the user enters a month-end date, and the system must gather transactions for that month. No problem, I thought, I'll just use the DateAdd...
1
by: C.Davidson | last post by:
Does subject VB.net 2003 support DateAdd function? I have tried to implement the following without success. In my example I tried to simply add 30 months to 9/18/2003 and I get "New date: 12:00:00...
2
by: Rich Raffenetti | last post by:
I have the following code. If I do the dateadd function with dateinterval.minute, it works fine and the date/time value is displayed with zero seconds. If I do the dateadd function with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.