Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Hour addition (http://www.outlookbanter.com/outlook-vba/53464-hour-addition.html)

Al[_2_] July 27th 07 04:19 PM

Hour addition
 
We have a program that trends our current plant steam usage and uses VBA
for applications. I'd like to use the do...loop and loop it until I reach
a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks

fredg July 27th 07 04:28 PM

Hour addition
 

"Al" wrote in message
9.11...
We have a program that trends our current plant steam usage and uses VBA
for applications. I'd like to use the do...loop and loop it until I reach
a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks


I have no idea what you mean by using a do..loop for this purpose,
but to add 8 hours to the current time, use:
=DateAdd("h",8,Now())

Fred



Brendan Reynolds July 27th 07 04:30 PM

Hour addition
 
"Al" wrote in message
9.11...
We have a program that trends our current plant steam usage and uses VBA
for applications. I'd like to use the do...loop and loop it until I reach
a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks



You don't need to loop to add eight hours to the current time, but you may
need it if you want to do something for each of the eight hours, so here are
examples with and without looping. See 'DateAdd Function' in the help files
for more information.

Public Sub EightHoursFromNow()

Dim dtmNow As Date

dtmNow = Now()
Dim intLoop As Integer

Debug.Print "No looping required: " & DateAdd("h", 8, dtmNow)
Debug.Print "------------------------------------------------"
Debug.Print "Starting loop"
For intLoop = 0 To 8
Debug.Print intLoop, DateAdd("h", intLoop, dtmNow)
Next intLoop

End Sub

--
Brendan Reynolds


Graham R Seach July 27th 07 04:34 PM

Hour addition
 
Al,

No need for a loop:
dteMyTime = DateAdd("h", 8, dteMyTime)

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia


"Al" wrote in message
9.11...
We have a program that trends our current plant steam usage and uses VBA
for applications. I'd like to use the do...loop and loop it until I reach
a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks



Paolo July 27th 07 04:36 PM

Hour addition
 
Hi Al,

Format(DateAdd("h", 8, Now), "hh:mm:ss")

HTH Paolo

"Al" wrote:

We have a program that trends our current plant steam usage and uses VBA
for applications. I'd like to use the do...loop and loop it until I reach
a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks


Al[_2_] August 1st 07 03:25 PM

Hour addition
 
Al wrote in
9.11:

We have a program that trends our current plant steam usage and uses
VBA for applications. I'd like to use the do...loop and loop it until
I reach a time 8 hours away.

How do I add 8 hours to the currect time?

Thanks


Thanks to all who responded, You all were correct in that I had no need
for the loop, It is work well, I just have to fine tune it now.


All times are GMT +1. The time now is 08:25 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com