473,782 Members | 2,507 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5306
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******** *************@f 14g2000cwb.goog legroups.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.t iscali.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******** *************@f 14g2000cwb.goog legroups.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
2471
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 to do, of course, but I have a really big Google ranking under the /something URL, and I'm afraid that if I transfer to the new URL, I'd lose all that.
1
1296
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 localization to its liking, mine will change it again upon (re)loading, and everyone is happy, as far as I'm concirned :) The problem I'm facing now is this:
4
1221
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 database for a youth club, with relevant info on members, non members, who attended what activity when etc etc. The thing I am trying to do is, each youngster will be in a particular year group in school (i.e. first year, second year etc), I have a...
1
1797
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()) + 65)))) Randomize() objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65)))) Randomize() objStringBuilder.Append(Chr(CInt(Int((25 * Rnd()) + 65)))) Randomize()
4
15887
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 gets stuck (I'm working on why that happens) and I want to kill it. I do a thread.abort and the status becomes abortrequested but never actually goes through. If it were an actual process I could kill it but there seems to be no real kill for...
6
1506
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 for the trees... I have to write a c module that gives the user a menu interface to various options. Dependant on the user, some/most/all menus can be
4
4111
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 process does not decrease after 'delete'. Is this because the heap allocator holds the deleted memory for future use? Is there anyway to force the release of the memory since we confront problem of memory allocation failure if the delete memory is...
0
2195
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 problems later). Apparently Point is a struct, a value type, and it does not behave like a classic structure (in my mind's eye, and see below). Traditionally I think of a classic structure as simply an object where every member is public. But with...
9
1706
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
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.