-
April 13th, 2009, 11:43 PM
#1
Adding time to Now()
I am hoping somone can help. I am making a small reminder program and want to add a certain amount of time to the current date and time. For example I might want to know the date and time of Now + 3 hours. Is there an easy way of doing this so that it will rollover after midnight if applicable? Any tips will be appreciated.
-
April 14th, 2009, 01:04 AM
#2
Re: Adding time to Now()
Use the DateAdd() function with Now as one of the parameters. You will find info on all the different params in your online help
Syntax
DateAdd(interval, number, date)
Settings
The interval argument has these settings:
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
Example:
Code:
Private Sub Command1_Click()
Dim TargetTime As Date
TargetTime = DateAdd("h", 3, Now())
MsgBox TargetTime
End Sub
-
April 14th, 2009, 01:10 AM
#3
Re: Adding time to Now()
Thank you so much, exactly what I need.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|