473,396 Members | 1,893 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.

Help with DaysDiff/HourDiff (not really datediff())

4 Fields:

Date1 Time1
Date2 Time2

How do I calculate days/hours diff between Date1Time1 & Date2Time2?

e.g. 3days 12hours

If it were 05/02/05 11pm and 05/03/05 8am? It should say 0day 9hrs.

If I have a bunch of these days/hrs diff, how do I come up with a
formulae to add them all up as well? I know if I do a sum(), I will
get a bunch of number again!

Thanks in advance.
Perry

Nov 13 '05 #1
4 5294
Perry,
Maybe you need to do something like the following:

First you will need to combine the fields Datex and Timex.
I don't know how your dates and times are formatted but as long as they are *real*
date,time fields you can convert them to long and just add the values.
So DateTime1= Clng(Date1) + Clng(Time1)
DateTime2= Clng(Date2) + Clng(Time2)
Then you can do a Datediff to count the hours. You can add the hours as you wish.
HoursDiff = DateDiff("h", DateTime1, DateTime2)
Your Result will be like CalcResult: HoursDiff \24 & " days " & HoursDiff Mod 24 & " hrs"

--
Hope this helps
Arno R

<pe******@yahoo.com> schreef in bericht
news:11*********************@f14g2000cwb.googlegro ups.com...
4 Fields:

Date1 Time1
Date2 Time2

How do I calculate days/hours diff between Date1Time1 & Date2Time2?

e.g. 3days 12hours

If it were 05/02/05 11pm and 05/03/05 8am? It should say 0day 9hrs.

If I have a bunch of these days/hrs diff, how do I come up with a
formulae to add them all up as well? I know if I do a sum(), I will
get a bunch of number again!

Thanks in advance.
Perry



Nov 13 '05 #2
Oops! Obviously I was a bit to fast with this ....

So DateTime1= Clng(Date1) + Clng(Time1)
DateTime2= Clng(Date2) + Clng(Time2)
Should read:
So DateTime1= Clng(Date1) + Cdbl(Time1)
DateTime2= Clng(Date2) + Cdbl(Time2)

Arno R
"Arno R" <ar****************@tiscali.nl> schreef in bericht
news:42**********************@dreader2.news.tiscal i.nl...
Perry,
Maybe you need to do something like the following:

First you will need to combine the fields Datex and Timex.
I don't know how your dates and times are formatted but as long as they are *real*
date,time fields you can convert them to long and just add the values.
So DateTime1= Clng(Date1) + Clng(Time1)
DateTime2= Clng(Date2) + Clng(Time2)
Then you can do a Datediff to count the hours. You can add the hours as you wish.
HoursDiff = DateDiff("h", DateTime1, DateTime2)
Your Result will be like CalcResult: HoursDiff \24 & " days " & HoursDiff Mod 24 & "
hrs"

--
Hope this helps
Arno R

<pe******@yahoo.com> schreef in bericht
news:11*********************@f14g2000cwb.googlegro ups.com...
4 Fields:

Date1 Time1
Date2 Time2

How do I calculate days/hours diff between Date1Time1 & Date2Time2?

e.g. 3days 12hours

If it were 05/02/05 11pm and 05/03/05 8am? It should say 0day 9hrs.

If I have a bunch of these days/hrs diff, how do I come up with a
formulae to add them all up as well? I know if I do a sum(), I will
get a bunch of number again!

Thanks in advance.
Perry




Nov 13 '05 #3
Arno, thanks. I will give it a try tomorrow.

Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4
Arno,
Thanks, your suggestions worked perfectly.

Perry

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #5

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

Similar topics

11
by: Paul Neave | last post by:
Hi group, hope you can help. I have a URL on my website that is currently under the directory mysite.com/something/ But I'd like to change the URL to mysite.com/anotherthing/ This is peasy...
1
by: evanescent.lurker | last post by:
Hi gang, I was thinking about further localization of my app. There is a problem with gettext since it is not thread aware, but I don't mind it, since if any other page changes the...
4
by: Will | last post by:
Hello all I'm not sure how to word this, which is one reason why I couldn't find anything on Google to help me, so please bear with me as I try to explain myself... I am trying to create a...
1
by: Radu | last post by:
As simple-to-remember-but-unique confirmation numbers, I need to generate six random characters (ASCII 65 to 90, inclusive): Randomize() objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) +...
4
by: Mufasa | last post by:
Is there any way to force a thread to abort and really have it abort? I have a thread that every once in a while gets hung to so I kill it. Problem is I have a thread that every once in a while...
6
by: all | last post by:
Hi, This isn't a C question more of a programming question, so I hope it's ok to post here (I will be coding it in C!) I've been racking my brains about this little problem and can't see wood...
4
by: Hong Chen | last post by:
I developed a large program and found the program does not really release memory after the delete operation is taken, since, according to "performance monitor", the virtual bytes used by this...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
9
by: mgrubbs | last post by:
#include <iostream> using std::cout; using std::cin; using std::endl; int main() { int code = 0; int charges = 0;
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.