Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 13th, 2005, 07:52 AM
perryche@yahoo.com
Guest
 
Posts: n/a
Default 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


  #2  
Old November 13th, 2005, 07:52 AM
Arno R
Guest
 
Posts: n/a
Default Re: Help with DaysDiff/HourDiff (not really datediff())

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



<perryche@yahoo.com> schreef in bericht
news:1109870383.066066.25880@f14g2000cwb.googlegro ups.com...[color=blue]
>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
>[/color]




  #3  
Old November 13th, 2005, 07:53 AM
Arno R
Guest
 
Posts: n/a
Default Re: Help with DaysDiff/HourDiff (not really datediff())

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" <arracomn_o_s_p_a_m@tiscali.nl> schreef in bericht
news:42275dc3$0$44087$5fc3050@dreader2.news.tiscal i.nl...[color=blue]
> 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
>
>
>
> <perryche@yahoo.com> schreef in bericht
> news:1109870383.066066.25880@f14g2000cwb.googlegro ups.com...[color=green]
>>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
>>[/color]
>
>
>
>[/color]




  #4  
Old November 13th, 2005, 07:53 AM
Perry Cheng
Guest
 
Posts: n/a
Default Re: Help with DaysDiff/HourDiff (not really datediff())

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!
  #5  
Old November 13th, 2005, 07:54 AM
Perry Cheng
Guest
 
Posts: n/a
Default Re: Help with DaysDiff/HourDiff (not really datediff())

Arno,
Thanks, your suggestions worked perfectly.

Perry



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

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.